基本的字符串处理转换。
喷一喷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;
}