Score UVA - 1585
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
5
OOXXOXXOOO
OOXXOOXXOO
OXOXOXOXOXOXOX
OOOOOOOOOO
OOOOXOOOOXOOOOX
Sample Output
10
9
7
55
30
HINT
简单的分数统计,不多解释,看代码就好。
Accepted
#include<stdio.h>
#include<string.h>
int main()
{
int sum;
scanf("%d", &sum);
while (sum--)
{
char s[81];
scanf("%s", s);
int len = strlen(s);
int score = 0, t = 0;
for (int i = 0;i < len;i++)
{
if (s[i] == 'O')score += ++t;
else t = 0;
}
printf("%d\n", score);
}
}
Score UVA - 1585的更多相关文章
- UVa 1585 Score --- 水题
题目大意:给出一个由O和X组成的串(长度为1-80),统计得分. 每个O的分数为目前连续出现的O的个数,例如,OOXXOXXOOO的得分为1+2+0+0+1+0+0+1+2+3 解题思路:用一个变量t ...
- 得分(Score,ACM/ICPC Seoul 2005,UVa 1585)
#include<stdio.h> int main(void) { char b; int t,cou,sum; scanf("%d",&t); getcha ...
- UVa 1585 - Score
得分是目前连续O 的个数,遇到X置0 #include <cstdio> #include <iostream> #include <cstring> using ...
- 得分(Score, ACM/ICPC Seoul 2005,UVa 1585)
#include<cstdio>#include<cstdlib>#include<cstring>int main(){ char s[80];//输入OOXXO ...
- UVa 1585 - Score - ACM/ICPC Seoul 2005 解题报告 - C语言
1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分. 2.思路 实在说不出了,这题没过脑AC的.直接贴代码吧.=_= 3.代码 # ...
- uva 1585 Score(Uva-1585)
vj:https://vjudge.net/problem/UVA-1585 不多说水题一个o一直加x就加的变为0 我的代码 #include <iostream> #include &l ...
- 【习题 3-1 UVA - 1585】Score
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟水题 [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #include <bits/stdc++.h ...
- UVa 1585 待解决
是在遇到第一个ooxx的时候会出错,会少算一个1 #include<stdio.h> int main() { int i,k=0,sum=0; char a[100]={"oo ...
- 苏州大学ICPC集训队新生赛第二场
A - Score UVA - 1585 水 #include<bits/stdc++.h> using namespace std; int main(){ int n; cin> ...
随机推荐
- ffmpeg:为视频添加静态水印
在ffmpeg中,添加水印需要用overlay滤镜,这是一个复杂滤镜,因为它需要两个输入,默认第一个输入是主画面,第二输入为水印,先执行一个简单的看看. 下面有两个文件,一个是可爱的大雄兔,一个是可爱 ...
- FreeRTOS操作系统最全面使用指南
FreeRTOS操作系统最全面使用指南 1 FreeRTOS操作系统功能 作为一个轻量级的操作系统,FreeRTOS提供的功能包括:任务管理.时间管理.信号量.消息队列.内存管理.记录功能等,可基本满 ...
- oracle之用户
命令都是在命令行窗口执行 创建用户 1)登陆管理员用户 sqlplus system/密码 sqlplus system/briup 注意不要以分号结尾 2)创建用户 create user 用户名 ...
- Android获取OneNET云平台数据
尝试HttpURLConnection "get"方式获取了www.baidu.com的数据后,试着获取OneNET云平台的设备数据(设备数据已成功上传至云平台) .java文件 ...
- 视频+图文串讲:MySQL 行锁、间隙锁、Next-Key-Lock、以及实现记录存在的话就更新,如果记录不存在的话就插入如何保证并发安全
导读 Hi,大家好!我是白日梦!本文是MySQL专题的第 27 篇. 下文还是白日梦以自导自演的方式,围绕"如何实现记录存在的话就更新,如果记录不存在的话就插入."展开本话题.看看 ...
- 阿里云CentOS8.0服务器配置Django3.0+Python 3.7 环境
---恢复内容开始--- 1. 下载并安装python # 安装Python3.7.6 wget https://www.python.org/ftp/python/3.7.6/Python-3.7. ...
- ServiceMesh
传统微服务架构 在微服务模式下,企业内部服务少则几个到几十个,多则上百个,每个服务一般都以集群方式部署,这时自然产生两个问题: 一.服务发现:服务的消费方(Consumer)如何发现服务的提供方(Pr ...
- Markdown(1)介绍
一.简介 Markdown 是一种轻量级标记语言,通过简单的标记语法使纯文本内容具有一定格式,使用户可以用易读易写的纯文本格式编写文档. Markdown 语言在 2004 由约翰·格鲁伯(英 ...
- vue核心---虚拟dom的实现
生成dom的过程 由vue模板生成虚拟dom 虚拟dom转换成真实dom渲染到html页面 代码实现 要实现的真实dom <div id="box"> <p cl ...
- 项目管理之Git
@[TOC]( Git命令:分支与合并)Git一款很好的项目版本管理工具,更是一款优秀的分布式项目管理工具.今天主要给大家介绍Git 强大的分支和合并功能,分支和合并可以说在实际的工作当中用到的是最多 ...