UVA1585 得分score
2017-11-08 23:52
260 查看
算法竞赛入门经典第二版 P57 习题3-1
感悟:第一次写就直接写出来了,此题较容易。
思路:对输入的字符串数组逐一判断。并定义一个中间变量,来形容O的递增情况。遇O递增,遇X归为0。
#include <stdio.h>#include <stdlib.h>
#include <string.h>
#define maxn 85
int main()
{ int tot=0,kase=0;
int T;
scanf("%d",&T);
char s[maxn];
while(T--){
scanf("%s",s);
int n=strlen(s);
for(int i=0;i<n;i++){
if(s[i]=='O')++kase;
if(s[i]=='X')kase=0;
tot+=kase;
}
}
printf("%d\n",tot);
return 0;
}
另附上个人做题心得:可以在for循环内加个printf表示Kase的变化情况,方便找出代码错误,以及验证代码正确性。
相关文章推荐
- 得分 (Score, ACM/ICPC Seoul 2005, UVa1585)
- uva 得分Score 1585
- 习题3-1 得分(Score, ACM/ICPC Seoul 2005, UVa 1585)
- 小紫书 习题 3-1(UVA 1585) 得分(Score)
- 算法竞赛入门经典(第2版)习题3-1 得分 Score UVa1585
- UVa 1585 Score(得分,水题)
- 算法竞赛入门经典习题3-1 得分(Score,ACM/ICPC Seoul2005,UVa1585)
- UVa 1585 Score 得分 (java版本)
- 得分(Score,ACM/ICPC Seoul 2005,UVa1585)
- 得分(Score, ACM/ICPC Seoul 2005, UVa1585)
- 算法竞赛入门经典 习题3-1 得分(Score, ACM/ICPC Seoul 2005, UVa1585)
- 得分(Score,ACM/ICPC Seoul 2005,UVa 1585)
- 《算法竞赛入门经典2ndEdition 》习题3-1 得分(Score, Uva1585)
- UVa 1585 Score(得分)
- 得分(Score,UVa1585)
- 得分(Score,ACM/ICPC Seoul 2005,UVa1585)
- Score UVA - 1585
- Score(模拟)uva1585
- 3-1 Score(P57) / UVA 1585
- uva_1585_Score