UVa1585 Score
来源:互联网 发布:怎么看windows 版本 编辑:程序博客网 时间:2024/05/21 11:18
就是说一个由O X组成的字符串,每个O得分为连续出现的O的个数,X得分为0;
如:OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3=10
原题:
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.
OOXXOXXOOO” is 10 which is calculated by “1+2+0+0+1+0+0+1+2+3”.
Therefore, the score of
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 byO' and
X’ and the length of the string is more than 0 and less than 80. There is no spaces betweenO' 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
sample output
10
9
7
55
30
代码如下:
#include<iostream>#include<string>using namespace std;int main() {string x;int m = 1;int sum = 0;int n;cin >> n;while (n--) {sum = 0;m = 1;cin >> x;for (int i = 0; i < x.size(); i++) {if (x[i] == 'O') {sum += m;m++;}else if(x[i]=='X') {m = 1;}}cout << sum;cout << endl;}return 0;}
- UVa1585 Score
- uva1585 - Score
- UVa1585 Score
- uva1585 Score
- UVa1585 Score
- UVa1585 Score
- UVa1585 Score
- UVa1585 Score
- UVa1585 Score
- UVA1585 Score
- uva1585 Score
- UVa1585-Score
- UVa1585 - Score(水题)
- UVa1585——Score
- Uva1585 Score (简单统计)
- Score(模拟)uva1585
- UVA1585 UVALive3354 Score
- 得分SCORE UVA1585
- 关于应用QT5连接MySQL数据库
- 【bzoj3119】【book】【贪心】
- ★ZZULIoj--1870(枚举好题)
- 事务总结
- 第六周 项目4-静态成员应用
- UVa1585 Score
- 第6周项目1-分数类的雏形(4)
- Intellij IDEA15:常用快捷键
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Qt中实现无边框的窗体
- 软件开发考虑几点
- 冒泡法排序
- C++作业3/2
- html5-canvas