acm题自己编了一个连输出都没有There is an objective test result such as "OOXXOXXOOO".An 'O' means a correct answer of a problem and an 'X' means a wrong answer.The score of each problem of this test is calculated by itself and its just pr

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 22:37:33

acm题自己编了一个连输出都没有There is an objective test result such as "OOXXOXXOOO".An 'O' means a correct answer of a problem and an 'X' means a wrong answer.The score of each problem of this test is calculated by itself and its just pr
acm题自己编了一个连输出都没有
There is an objective test result such as "OOXXOXXOOO".An 'O' means a correct answer of a problem and an 'X' means a wrong answer.The score of each problem of this test is calculated by itself and its just previous consecutive 'O's only when the answer is correct.For example,the score of the 10th problem is 3 that is obtained by itself and its two previous consecutive 'O's.
Therefore,the score of "OOXXOXXOOO" is 10 which is calculated by "1+2+0+0+1+0+0+1+2+3".
You are to write a program calculating the scores of test results.
Input
Your program is to read from standard input.The input consists of T test cases.The number of test cases T is given in the first line of the input.Each test case starts with a line containing a string composed by 'O' and 'X' and the length of the string is more than 0 and less than 80.There is no spaces between 'O' and 'X'.
Output
Your program is to write to standard output.Print exactly one line for each test case.The line is to contain the score of the test case.
The following shows sample input and output for five test cases.
Sample Input
5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX
Output for the Sample Input
10
9
7
55
30
#include
using namespace std;
int main()
{
int m=0,N,a=0,b=0,i,j;
string str[100];
cin>>N;
for(i=1;istr[j]; m=m+1;
if(str[j]==" ")
continue;
}
for(j=1;j

acm题自己编了一个连输出都没有There is an objective test result such as "OOXXOXXOOO".An 'O' means a correct answer of a problem and an 'X' means a wrong answer.The score of each problem of this test is calculated by itself and its just pr
我倒是写了一个能运行的
#include
int Calc(char szBuffer[])
{
char * p = szBuffer;
int iAll = 0;
bool bTemp = false;
int iCount = 1;
while (*p)
{
if (*p == 'O')
{
if (bTemp) ++iCount;
else
{
iCount = 1;
bTemp = true;
}
iAll += iCount;
}
else
{
bTemp = false;
}
++p;
}
return iAll;
}
int main()
{
int iNumber = 0;
scanf("%d", &iNumber);
getchar();
char szBuffer[256];
int iBuffer[256];
int i = 0;
for (i = 0; i < iNumber; ++i)
{
gets(szBuffer);
iBuffer[i] = Calc(szBuffer);
}
for (i = 0; i < iNumber; ++i)
{
printf("%d\n", iBuffer[i]);
}
return 0;
}
另外,关于你的程序
if(str[j]=="O"&&str[j-1]=="X")是判断字符,还是判断字符串啊?

acm题自己编了一个连输出都没有There is an objective test result such as OOXXOXXOOO.An 'O' means a correct answer of a problem and an 'X' means a wrong answer.The score of each problem of this test is calculated by itself and its just pr 连自己都迷失了 英文怎么说 英语翻译句子如下:明知道天下没有什么人是自己的对手了,却偏偏连、偏偏连竞逐的资格都没有. 为了你,我连自己都不认识自己了,英文翻译 汉族为什么没有自己的民族服饰?作为一个拥有几千年文明的民族,居然连自己的民族服饰都没有,真不知道这是不是一种悲哀! 世界地图 有标注山脉海峡的山脉、海、海峡能看得清晰的肿么没有人回答了其实我自己已经找到很多张了唉居然连一个态度好的都没有 哪个科学家连自己吃没吃饭都忘记了 16岁的孩子连1年级的算数都不会 该怎么办啊去医院看了 医生说智力没有大问题 现在没读书了 连自己的生活都照顾不好 别说适应社会了.主要一个问题是他什么也记不住/ 刚学的东西没过几 我们现在该如何善待自己!就是在工作,生活中没有好好的对待自己!就连吃饭都不准时了! 层次分析法例题请多给几个啊我早看过了,那里只有一个题,而且不是什么例题,连题目都没有 电源板单独维修,怎样连接测试电源板,创维37L05HR液晶,开机红灯亮,测12V 24V有输出,3秒后跌没了,电源板单独维修,在12V上接了一个12V灯泡,我把STBY5V连接到ON/OFF,把其他连接都脱开,开机12V 24V没有 acm 中的概率题问题大致是这样的:共有n个人,n个位置,每个人都对应着一个自己的位置,假设大家随机选择座位坐,全部人都做错位置的概率是多少 我是一个悲观主义者~这一两年无论是感情还是事业我都受了不少挫折,越来月发现自己是一个悲观主义者,我常会觉得未来是没有希望的,情绪波动很大.我常常需要别人安慰,连我自己都觉得自 忽然间才发现原来我连一个述说心事的人都没有我是不是白活了这些年 一道算法题,算法好或者搞ACM的童鞋看过来~题目在这里:首先说这道题目不是很难,但是我自己想了一个算法,我认为挺对的,使用的例子都能得到正确答案,但是怎么都通不过去,我知道标准的话 有没有儿歌童谣?自己编的 带冰和数的四字成语同音字或者自己编的好听一点也可以!急求!谢谢了!要两个字都在一个成语里! 英文名能自己编吗?我自己想了一个叫 Isokey