注意应该判断字符串" no good"(NO前有空格)
#include <iostream>
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char a[20],b[20];
int n;
while(cin>>n&&n)
{
memset(a,'-',sizeof(a));
memset(b,'-',sizeof(b));
int m=(n+1)/2;
int i=0;
getchar();
for(int j=0;j<n;j++)
{
string p,q;
getline(cin,p);
int nn=p.length();
if(nn<7)
{
p="hello"+p;
nn=p.length();
}
//cout<<p<<endl;
q=p.substr(nn-8,8);
//cout<<q<<endl;
if(q!=" no good")
{
if(i%2==1)
a[i/2]='O';
else
b[i/2]='O';
}
else if(q==" no good")
{
if(i%2==1)
a[i/2]='X';
else
b[i/2]='X';
}
i++;
}
for(int k=0;k<m;k++)
{
cout<<k+1<<" ";
}
int sum=0;
cout<<"Score"<<endl;
for(int k=0;k<m;k++)
{
cout<<b[k]<<" ";
if(b[k]=='O')
sum++;
}
cout<<sum<<endl;
sum=0;
for(int k=0;k<m;k++)
{
cout<<a[k]<<" ";
if(a[k]=='O')
sum++;
}
cout<<sum<<endl;
sum=0;
}
return 0;
}