题目描述:
思路:读入字符串,扫描一遍,连续出现的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 ", score); 20 --n; 21 } 22 }