Simple string handling
Pit point, someone may not have a name (the name is empty)
Someone's name might be Blablablano.
But because the input guarantees that the last five characters are good (preceded by a space)
Because if the input means no good, no front must have a space
So you just have to judge whether the 6th, 7, 8 characters are ', ' n ', ' O '.
Of course, if the name appears empty, the result is good, the string length is less than 8, to determine the length of the string
After the above solution a little attention to the output format can be
#include <cstdio> #include <cstring>using namespace std;int t;char info[105];int Len;char result[2][20];int Score[2];void Initialize () {memset (info, 0, sizeof info), memset (result, 0, sizeof result), memset (score, 0, sizeof score); len = 0;} int main () {while (~SCANF ("%d", &t) && t) {Initialize (); and while (GetChar ()! = ' \ n '); for (int i = 0; i < T; + +) i) {gets (info), Len = strlen (info), if (Len > 8 && info[len-8] = = ' && info[len-7] = = ' n ' &&am P INFO[LEN-6] = = ' O ') result[i & 1][i >> 1] = ' X ', else Result[i & 1][i >> 1] = ' O ', ++score[i & 1]; }for (int i = 1; I <= t + 1 >> 1; ++i) printf ("%d", i);p UTS ("score"); if (T & 1) result[1][t >> 1] = '- ' for (int i = 0; i < 2; ++i) {for (int j = 0; J << 1 < T; ++j) Putchar (Result[i][j]), Putchar (");p rintf ("%d\ N ", Score[i]);}} return 0;}
Cdoj 25-point ball battle (penalty) problem Solving report