总时间限制: 1000ms 内存限制: 65536kB描述
给定一个完全由数字字符('0','1','2',…,'9')构成的字符串str,请写出str的p型编码串。例如:字符串122344111可被描述为"1个1、2个2、1个3、2个4、3个1",因此我们说122344111的p型编码串为1122132431;类似的道理,编码串101可以用来描述1111111111;00000000000可描述为"11个0",因此它的p型编码串即为110;100200300可描述为"1个1、2个 0、1个2、2个0、1个3、2个0",因此它的p型编码串为112012201320。
输入输入仅一行,包含字符串str。每一行字符串最多包含1000个数字字符。输出输出该字符串对应的p型编码串。样例输入
122344111
样例输出
1122132431
1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<cstring>
5 using namespace std;
6 char a[10001];
7 int tot=1;
8 int main()
9 {
10 gets(a);
11 int l=strlen(a);
12 for(int i=0;i<l;i++)
13 {
14 if(a[i]==a[i+1])
15 {
16 tot++;
17 }
18 else
19 {
20 cout<<tot<<a[i];
21 tot=1;
22 }
23 }
24 return 0;
25 }