1005 点球大战
1005 点球大战
View Code
This is also a simple problem. But what you should care is that you may need to judge each string from its tail. because the name of the players may have some trouble in your programming. what's more,you should be careful of the form of output !
Ok, next come the AC code! you can refer to it but not depends heavily on it !
View Code
1 #include <stdio.h>
2 #include <string.h>
3 main()
4 {
5 int T,n,k,m,i,j,l;
6 double b,c;
7 while(scanf("%d",&n)&&n!=0)
8 { char ch[n][101];
9 for(i=0;i<(n+1)/2;i++)
10 printf("%d ",i+1);
11 puts("Score");
12 gets(ch[0]);
13 for(i=0;i<n;i++)
14 gets(ch[i]);
15 m=0;j=1;
16 for(i=0;i<n;i=i+2)
17 {
18 l=strlen(ch[i]);
19 if(ch[i][l-5]==' '&&ch[i][l-8]==' '&&ch[i][l-6]=='o'&&ch[i][l-7]=='n') printf("X ");
20 else {printf("O ");m++;}
21 }
22 printf("%d\n",m);
23 m=0;j=1;
24 for(i=1;i<n;i=i+2)
25 {
26 l=strlen(ch[i]);
27 if(ch[i][l-5]==' '&&ch[i][l-8]==' '&&ch[i][l-6]=='o'&&ch[i][l-7]=='n') printf("X ");
28 else {printf("O ");m++;}
29 }
30 if(n%2!=0) printf("- %d\n",m);
31 else printf("%d\n",m);
32 }
33 }
34
35

浙公网安备 33010602011771号