UVA - 1585 Score

news/2024/11/25 13:33:50/

Description

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.

 Sample Input

 

 Sample Output

10

9

7

55

30

 

#include <cstdio>
#include <cstring>using namespace std;char s[1000];int main()
{int n = 0;scanf("%d", &n);while(n--){scanf("%s", s);int len = strlen(s);int sum = 0, count = 0;for (int i = 0; i < len; i++){if ('O' == s[i]){count++;//计数连续的个数sum += count;}else{count = 0;}}printf("%d\n", sum);}return 0;
}

 


http://www.ppmy.cn/news/790777.html

相关文章

装修知识笔记

文章目录 衣柜要不要到顶?办公柜 改水电布局家具吊顶吊顶种类吊顶架子 隔墙 门如何安装门电视背景墙和电视柜悬空电视柜 采光卫生间防水和下水 非专业专修人员&#xff0c;只是喜爱&#xff0c;毕竟多懂一点&#xff0c;自己的家就有机会舒适一些。 衣柜 为什么放到最前面&am…

以阻塞方式对IO文件进行读取

以阻塞方式对IO文件进行读取(test.c读取&#xff0c;test2.c发送数据) 实验结果 执行test.c生成的pro1可执行文件&#xff0c;光标显示处于阻塞状态 执行test2.c生成的pro2可执行文件&#xff0c;test.c处打印 hello dhl 三级标题test.c #include <stdlib.h> #inclu…

十三亿人都能看懂的导航栏吸顶+tab

设计思路 要想出现滚动效果,就需要让里面的内容高度大于外面内容的高度\ <body> <div class"box"> <div class"top"> <img src"../img/ad.jpg" alt""> </div> <…

不破不立~EDG夺冠,用Python分析词云图展示粉丝弹幕数据,来感受粉丝的热情吧

大家好~我是恰恰&#xff0c;好久不见啦~Python的乐趣就在于在互联网时代&#xff0c;能实现很多人工做不到的事~ 虽然我不是经常玩游戏&#xff0c;但是我这该死的爱国情怀&#xff0c;在EDG夺冠的时候&#xff0c;我也是十分激动的&#xff01; 北京时间11月6日&#xff0…

iMeta | 南昌大学丁霞等-水产养殖系统对中华鳖微生物组和肠道代谢组的影响

点击蓝字 关注我们 水产养殖模式对水产动物皮肤、口腔和肠道微生物群落组装及宿主适应性的影响 https://doi.org/10.1002/imt2.17 4.5 iMeta RESEARCH ARTICLE ● 2022年4月5日&#xff0c;南昌大学丁霞等在iMeta在线发表题为“The impact of aquaculture system on the microb…

lol服务器位置地图,LOL老玩家一定能看懂的地图 每一个地点都充满回忆

英雄联盟赛事发展至今&#xff0c;已经从最初的小打小闹&#xff0c;发展到现如今的全球性的大型盛会。而每年的比赛上都会留下令人津津乐道的招牌操作&#xff0c;这些操作或搞笑或惊艳。 而近日&#xff0c;就有一位能人就将这些最经典的操作用梗的形融合在了召唤师峡谷地图上…

AndroidStudio一键国际化方案

预研 国际化对于只做国内市场的小伙伴来说基本没有太多感觉&#xff0c;但是对于做国外市场特别是谷歌市场的朋友来说却是需要重视的一个知识点。因为海外市场面对的全球的客户&#xff0c;而如果人工翻译势必很费时费力而且低效&#xff0c;这时候我们需要程序化来实现这个体…

世界各国浏览器语言代码本地化对照表

阿尔巴尼亚语 [sq] 阿尔巴尼亚语(阿尔巴尼亚) [sq-AL] 阿尔萨斯语 [gsw] 阿尔萨斯语(法国) [gsw-FR] 阿拉伯语 [ar] 阿拉伯语(阿尔及利亚) [ar-DZ] 阿拉伯语(阿联酋) [ar-AE] 阿拉伯语(阿曼) [ar-OM] 阿拉伯语(埃及) [ar-EG] 阿拉伯语(巴林) [ar-BH] 阿拉伯语(卡塔尔) [ar-QA…