解题思路:
注意事项:
参考代码:
#include<iostream> #include<string> #include<algorithm> using namespace std; string s1; string s2; char num[10]; void itoc(int n) { int k=0; while(n) { num[k++]=n%10+'0'; n/=10; } num[k]=0; } int main() { int n; cin>>s1>>n; while(n--) { char c=s1[0]; int as=0; int k=0; for(int i=0;i<s1.size();i++) { if(c==s1[i]) { as++; if(c!=s1[i+1]) { if(as>9) { itoc(as); for(int h=0;num[h]!=0;h++) s2.insert(k++,1,num[h]); } else { itoc(as); s2.insert(k++,1,num[0]); } s2.insert(k++,1,s1[i]); c=s1[i+1]; as=0; } } } s1.clear(); s1=s2; s2.clear(); } cout<<s1<<endl; return 0; }
0.0分
0 人评分
三角形 (C++代码)递推浏览:760 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:639 |
Hello, world! (C++代码)浏览:1744 |
1025题解浏览:738 |
1197求助浏览:629 |
数列排序 (C语言代码)浏览:616 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:691 |
简单的a+b (C语言代码)浏览:647 |
简单的a+b (C语言代码)浏览:463 |
【亲和数】 (C++代码)浏览:534 |