UVaOJ 1585 Score AC代码示例

 1 #include<stdio.h>
 2 #include<string.h>
 3 #define maxn 90
 4 char s[2][maxn];
 5 int main()
 6 {
 7     int T=0;
 8     scanf("%d",&T);
 9     
10    while(T--){
11    memset(s,0,sizeof(s));
12    scanf("%s",s);
13  
14    if(s[0][0]=='O')    s[1][0]=1;
15    else s[1][0] = 0;
16   int i,j; 17   for(i=1;i<strlen(s);i++){ 18     if(s[0][i]=='O') s[1][i] = s[1][i-1]+1; 19   } 20   int sum = 0; 21   for(j=0;j<strlen(s);j++){ 22      sum = sum+s[1][j]; 23   } 24   printf("%d\n",sum); 25 } 26 27 return 0; 28 }

 以上代码经过ANSI C 即可通过测试。

 

转载于:https://www.cnblogs.com/MindPalace/p/7463388.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值