hdu2539:点球大战



#include
#include
//#include
using namespace std;

int main()
{
//    freopen("in.in", "r", stdin);
    int N, len, turn, i, j, score[2];
    char str[120], xo[2][10];
    while(cin >> N && N != 0)
    {
        cin.get();//吃掉空格
        turn = 0;
        i = 0;
        score[0] = score[1] = 0;
        for(j = 0; j < N; j++)
        {
            cin.getline(str, 120);
            len = strlen(str);
            if(len - 8 > 0 && strcmp(str + len - 8, " no good") == 0)
                xo[turn][i] = 'X';
            else
            {
                xo[turn][i] = 'O';
                score[turn]++;
            }
            i += turn;
            turn ^= 1;
        }
        if(N & 1)
            xo[turn][i] = '-';
        for(j = 1; j <= (N + 1) / 2; j++)
            cout << j << ' ';
        cout << "Score" << endl;
        for(j = 0; j < (N + 1) / 2; j++)
            cout << xo[0][j] << ' ';
        cout << score[0] << endl;
        for(j = 0; j < (N + 1) / 2; j++)
            cout << xo[1][j] << ' ';
        cout << score[1] << endl;
    }
//    fclose(stdin);
    return 0;
}

你可能感兴趣的:(ACM,CC++,ACM,hdu,水题)