标签:
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1020
题目:
1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <queue> 7 #include <stack> 8 #include <map> 9 #include <vector> 10 11 #define PI acos((double)-1) 12 #define E exp(double(1)) 13 using namespace std; 14 15 int main (void) 16 { 17 int t,n; 18 char a,b; 19 cin>>t; 20 scanf("%*c"); 21 while(t--) 22 { 23 n=1; 24 scanf("%c",&a); 25 while(scanf("%c",&b)==1 && b!=‘\n‘) 26 { 27 if(a == b) 28 { 29 n++; 30 } 31 else 32 { 33 if(n>1) 34 printf("%d%c",n,a); 35 else 36 printf("%c",a); 37 n=1; 38 a=b; 39 } 40 } 41 if(n>1) 42 printf("%d%c\n",n,a); 43 else 44 printf("%c\n",a); 45 } 46 return 0; 47 }
标签:
原文地址:http://www.cnblogs.com/weeping/p/5351848.html