0
点赞
收藏
分享

微信扫一扫

HDOJ  1020   Encoding

小贴贴纸happy 2022-08-23 阅读 148


题目:​​http://acm.hdu.edu.cn/showproblem.php?pid=1020​​

经常WA请进来看看..............

就是题目表述有问题:字符算得是相邻的相同的个数
eg:如果碰到AABBBCCCABC的话,应该是2A3B3CABC

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int n,a;
char str[26];
string s;
cin>>n;
while(n--)
{
cin>>s;
s+='0';
for(int j=1,i=0;j<s.length();j++)
{
if(s[i]!=s[j])
{
a=j-i;
if(a==1)
cout<<s[i];
else
cout<<a<<s[i];
i=j;
}
}
cout<<endl;
}
return 0;
}

举报

相关推荐

1020 月饼

1020.月饼

1020-1026

1020:打印ASCII码

New Online Judge 1020

0 条评论