ural 2073 - Log Files 模擬

題意:給出一個人在一場比賽的提交記錄,按照格式輸出,這個題基本看輸入輸出就能看懂題意了。

算是比較簡單的模擬,沒什麼坑,只要注意一個題AC以後再提交的時候不要修改成X就好。

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct node {
    char nm[100], dt[20], rs[20];
    void init(int u) {

        if(u) {
            for(int i = 0; i < u; i++)
                rs[i] = '.';
            rs[u] = 0;
            return;
        }
        strcpy(nm, "Contest name");
        strcpy(dt, "Date");
        strcpy(rs, "ABCDEFGHIJKLM");
    }
    void ouput() {
        printf("|%s", nm);
        for(int i = strlen(nm); i < 30; i++)
            printf(" ");
        printf("|%s", dt);
        for(int i = strlen(dt); i < 8; i++)
            printf(" ");
        printf("|%s", rs);
        for(int i = strlen(rs); i < 13; i++)
            printf(" ");
        printf("|\n");
    }
}id[111], inf;
char ch[] = "+------------------------------+--------+-------------+\n";
char s[200];
int main() {
    int t, n, m, i, j;
    inf.init(0);
    while(~scanf("%d%*c", &t)) {
        for(i = 0; i < t; i++) {
            gets(id[i].nm);
            gets(id[i].dt);
            scanf("%d%d%*c", &n, &m);
            id[i].init(n);
            while(m--) {
                gets(s);
                if(s[2] == 'A')
                    id[i].rs[s[0] - 'A'] = 'o';
                else if(id[i].rs[s[0] - 'A'] != 'o')
                    id[i].rs[s[0] - 'A'] = 'x';
            }
        }
        printf("%s", ch);
        inf.ouput();
        for(i = 0; i < t; i++) {
            printf("%s", ch);
            id[i].ouput();
        }
        printf("%s", ch);

    }
    return 0;
}


發佈了67 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章