UVa1585 得分

题目描述:

思路:读入字符串,扫描一遍,连续出现的O递增分数,累加在总得分上,出现X就将递增分数归为为1。

 1 #include <stdio.h>
 2 #include <string.h>
 3 int main()
 4 {
 5     int n;
 6     char s[200];
 7     scanf("%d", &n);
 8     while(n > 0){
 9         scanf("%s", s);
10         int points = 1, score = 0;
11         for(unsigned i = 0; i < strlen(s); ++i){
12             if(s[i] == 'O'){
13                 score += points;
14                 ++points;
15             }else{
16                 points = 1;
17             }
18         }
19         printf("%d\n", score);
20         --n;
21     }
22 }

 

posted @ 2019-07-11 16:08  patrolli  阅读(117)  评论(0编辑  收藏  举报