http://acm.hdu.edu.cn/showproblem.php?pid=1020大水题一个不解释

来源:岁月联盟 编辑:exp 时间:2012-07-27
[cpp] 
#include<string> 
#include<cstdio> 
#include<map> 
#include<algorithm> 
#include<string.h> 
#include<cmath> 
#include<iostream> 
using namespace std; 
int main() 

 int t; 
 scanf("%d",&t); 
 string str; 
  while(t--) 
  { 
      map<char,int>M; 
       cin>>str; 
 
    for(int i=0;i<str.size();i++) 
    { 
      char p=str[i]; 
      int kk=0; 
      while( ++i < str.size() && p==str[i] )kk++; 
      i--; 
      if(kk==0) 
      { 
       printf("%c",p); 
      }else 
      { 
      printf("%d%c",kk+1,p); 
      } 
    } 
    printf("/n"); 
  } 
    return 0; 

作者:Java_beginer1