算法竞赛入门经典3.1 得分UVa1585
2016-07-27 21:05
351 查看
#include <iostream>
#include <string>
using namespace std;
int main()
{ int n;
cout<<"please input the number"<<endl;
cin>>n;
while (n--)
{
int m = 0, t = 0, i = 0;
string s;
cout<<"please input the string"<<endl;
cin>>s;
while (i <= s.length() - 1)
{
if (s[i] == 'X') m = 0;
else
{
m++;
t += m;
}
i++;
}
cout<<t<<endl;
}
return 0;
}
#include <string>
using namespace std;
int main()
{ int n;
cout<<"please input the number"<<endl;
cin>>n;
while (n--)
{
int m = 0, t = 0, i = 0;
string s;
cout<<"please input the string"<<endl;
cin>>s;
while (i <= s.length() - 1)
{
if (s[i] == 'X') m = 0;
else
{
m++;
t += m;
}
i++;
}
cout<<t<<endl;
}
return 0;
}
相关文章推荐
- DC/OS专题之安装部署篇
- tjut 4627
- 原码补码反码之间的关系
- yii2中sphinx搜索 多条件选择搜索
- 不敢死队问题
- poj1213Fantasy of a Summation(找规律,优化代码)
- JAVA学习随笔(6)--FileInputStream随笔
- 用Mac终端编写,编译C程序的实例
- SwitchButton 的使用汇总 —— 定制漂亮的开关控件
- python(五) 对数组排序
- volley三种基本请求图片的方式与Lru的基本使用:正常的加载+含有Lru缓存的加载+Volley控件networkImageview的使用
- HDU 1702
- POJ 2492 二分图判断 并查集
- HDU 5753 Permutation Bo
- 超级链接的美化
- 洛谷 P1428 小鱼比可爱
- 10010---数据研发专家
- iOS开发 ☞ 时间格式相关
- 状压DP——彩虹小马与魔法数列
- UVA 10012 How Big Is It?