码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 1020 Encoding 字符串

时间:2014-07-27 11:16:12      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

基本的字符串处理转换。

喷一喷HDU这个超级垃圾的判断系统:如果把数字存入字符串数组中输出就会错误。

如:A2B3C,如果其中的2和3保存如字符串数组中,然后输出那么就判断为WA,必须是即时输出数字2和3才算正确。

这样判我WA,哎, HDU做好点你们的判断系统吧。

#include <string>
#include <iostream>
using namespace std;

int main()
{
	int T;
	string s;
	scanf("%d", &T);
	while (T--)
	{
		cin>>s;
		int c = 1;
		char a = s[0];
		for (unsigned i = 1; i < s.size(); i++)
		{
			if (a == s[i]) c++;
			else
			{
				if (c > 1) cout<<c;//测试这样输出为错误cout<<char(c+'0');实际应该为正确,判断系统垃圾。
				cout<<a;
				c = 1;
				a = s[i];
			}
		}
		if (c > 1) cout<<c;
		cout<<a<<endl;
	}
	return 0;
}



HDU 1020 Encoding 字符串

标签:

原文地址:http://blog.csdn.net/kenden23/article/details/38167293

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!