这题是开胃小菜,顺利做出。
#include<stdio.h>
#include<string.h>
char s[85];
int main()
{
int T, tot, cnj;
scanf("%d", &T);
while(T--)
{
memset(s, 0, sizeof(s));
scanf("%s", s);
tot = 0; cnj = 0;
for(int i = 0; i < sizeof(s); i++)
{
if( s[i] == 'O')
{
cnj++;
tot += cnj;
}
else cnj = 0;
//printf("i= %d tot= %d cnj= %d \n", i, tot, cnj);
}
printf("%d\n", tot);
}
return 0;
}
本文介绍了一段使用C语言编写的程序,该程序能够针对输入的一系列字符(特别是'O'字符),计算出相应的得分。具体实现中采用了字符串处理和循环逻辑来跟踪连续'O'字符的数量,并据此累加得分。

被折叠的 条评论
为什么被折叠?



