博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【 OJ 】Score
阅读量:6956 次
发布时间:2019-06-27

本文共 1348 字,大约阅读时间需要 4 分钟。

Score

描述

  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.

输入

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'.

输出

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.

样例输入

5OOXXOXXOOOOOXXOOXXOOOXOXOXOXOXOXOXOOOOOOOOOOOOOOXOOOOXOOOOX

样例输出

10975530

源码

1 #include 
2 int main(){ 3 int n; 4 int i = 0; 5 int j = 0; 6 int score; 7 int sum = 0; 8 char str[80]; 9 scanf("%d",&n);10 while(i

 

转载于:https://www.cnblogs.com/forfriendforfun/p/8030114.html

你可能感兴趣的文章
.NET跨平台实践:用C#开发Linux守护进程
查看>>
大数据量分页优化
查看>>
MongoDB 可视化管理工具 MongoCola-1.0.4发布
查看>>
office2007安装时,提示找不到Office.zh-cn下的OfficeMUI.msi解决方法
查看>>
Vue 组件之间传值
查看>>
jtable 的简单使用
查看>>
XED中文亂碼
查看>>
浏览器json数据格式化
查看>>
创建帧动画
查看>>
Django Models一对多操作
查看>>
window - BOM对象
查看>>
IIS部署web,字体404的问题
查看>>
【学习——字符串】字符串之一网打尽quq
查看>>
Python中的multiprocessing和threading
查看>>
Stanford NLP学习笔记:7. 情感分析(Sentiment)
查看>>
程序员最应该真正读的书籍
查看>>
ubuntu下安装程序的三种方法
查看>>
js之全选即点击全选标签可选择全部复选框
查看>>
自我介绍
查看>>
垂直外边距叠加问题
查看>>