[恢]hdu 2539
2011-12-31 19:37:25
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2539
题意:中文。有点点麻烦的模拟。
代码:
# include <stdio.h>
# include <string.h>
char str[110] ;
int goal[20] ;
int judge (char s[])
{
int len = strlen(s) ;
if (len < 10) return 1 ;
if (s[len-8] == ' ' &&
s[len-7] == 'n' &&
s[len-6] == 'o' &&
s[len-5] == ' ') return 2 ;
return 1 ;
}
int main ()
{
int T, i, n, score ;
while (~scanf ("%d%*c", &n), n)
{
for (i = 0 ; i < n ; i++)
{
gets (str) ;
goal[i] = judge(str) ;
}
for (i = 1 ;i <= (n+1)/2 ; i++)
printf ("%d ", i) ;
printf ("Score\n") ;
for (i = 0, score = 0 ; i < n; i+=2)
{
printf ("%c ", (goal[i] == 1) ? 'O' : 'X') ;
score += (goal[i] == 1) ;
}
printf ("%d\n", score) ;
for (i = 1, score = 0 ; i < n ; i+=2)
{
printf ("%c ", (goal[i] == 1) ? 'O' : 'X') ;
score += (goal[i] == 1) ;
}
if (n &1) printf ("- ") ;
printf ("%d\n", score) ;
}
return 0 ;
}