您的位置:首页 > 其它

hdu1020--Encoding HDU(133)

2013-09-02 18:01 260 查看
【题目】点击打开链接

【题解】简单问题,不过需要注意题意说的是连续相同的字母!!!

#pragma warning(disable:4786)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<ctime>
#include<string.h>
using namespace std;
#define pi acos(-1.0)
//#define LL __int64
typedef long long LL;
#define INF 0x7fffffffffffffff
#define bug puts("hear!")
#define inf 0x7fffffff
#define eps 1e-10
#define FRE freopen("in.txt","r",stdin)
#define E exp(1.0)
#define mod 1000000007
char str[10005];
int main ()
{
int t ;
while( scanf("%d" , &t ) != EOF )
{
while( t-- )
{

scanf("%s" , str);
int len = strlen ( str );
for( int i = 0 ; i < len ; i++  )
{
int hh = 1 ;
for( int j = i+1 ; j < len ; j++ )
if( str[i] == str[j] )hh++;
else break;
if( hh > 1 )
printf("%d%c", hh , str[i] );
else
printf("%c" , str[i]);

i +=(hh-1);
}
puts("");
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: