习题3-1 score

来源:互联网 发布:怎么做seo 编辑:程序博客网 时间:2024/06/16 11:31
#include <stdio.h>#include <string.h>#define maxn 81char s[maxn];int main(){    //input n    int n=0;    scanf("%d",&n);    //input n times    for(int i=0;i<n;i++)    {        scanf("%s",s);        int len=strlen(s);        //printf("%d",len);        /*         * for(int i=0;i<len;i++)         *  printf("%c",s[i]);         */        //连续出现O的计算        int tempscore=0;//当前连续O数(不算当前这个数)        int totalcount=0;        for(int i=0;i<len;i++)        {            if(s[i]=='O')//连续第一个O            {                tempscore++;                totalcount+=tempscore;            }            if(s[i]=='X')            {                tempscore=0;            }        }        printf("%d\n",totalcount);    }}

0 0
原创粉丝点击