Problem Description
Given a string containing only 'A' - 'Z', we could encode it using the following method:
1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only character in this sub-string.
2. If the length of the sub-string is 1, '1' should be ignored.
 
Input
The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only 'A' - 'Z' and the length is less than 10000.
 
Output
For each test case, output the encoded string in a line.
 
Sample Input
2
ABC
ABBCCC
 
Sample Output
ABC
A2B3C
 
Author
ZHANG Zheng

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> using namespace std; char s[]; int main()
{
int z;
cin>>z;
getchar();
while(z--)
{
int i,j,k,l;
gets(s);
l = strlen(s);
int t = ;
for(i = ;i<=l;i++)
{
if(s[i]!=s[i-])
{
if(t!=) printf("%d",t);
putchar(s[i-]);
t = ;
}
else t++;
}
puts("");
}
return ;
}

hdu1020Encoding的更多相关文章

  1. HDU-1020-Encoding(水题,但题目意思容易搞错,英语的问题)

    题目链接 http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?pid=1000&ojid=0&cid=7996&h ...

  2. HDU-1020-Encoding,题意不清,其实很水~~

    Encoding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) http:// ...

随机推荐

  1. 11 java 反射机制

    Java反射机制的适用场景及其利与弊: http://blog.csdn.net/zolalad/article/details/29370565 http://my.oschina.net/u/10 ...

  2. Arbitrage HDU

    Arbitrage                                              Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  3. 【JAVA编码专题】总结

    第一部分:编码基础 为什么需要编码:用计算机看得懂的语言(二进制数)表示各种各样的字符. 一.基本概念 ASCII.Unicode.big5.GBK等为字符集,它们只定义了这个字符集内有哪些字符,以及 ...

  4. Alert方法重写

    在正规项目中,总感觉alert框是非常难看的,但是有的时候又必须添加alert框来给用户一种警醒,废话不多说,先上图

  5. C语言中关于字符串的一些常用函数

    使用以下时应当在头文件中加入string.h getch()为当你键入任何一个值时,返回但是并不显示,立马编译结束,返回的是asc码  getchar():当你键入回车之后才算是输入结束,并且可以用p ...

  6. mvc4 基于Area实现插件模块化开发

    对于一个较大规模的Web应用,可以从功能上通过Area将其划分为为较小的单元.每个Area相当于一个独立的子系统,具有一套包含Model.Views和Controller在内 的目录结构和配置文件.一 ...

  7. Qt自定义圆周动画(360 10.0 的模仿作者写的)

    由于项目需求,需要把一张图片做圆周运动,用到了属性动画,坐标计算等. 在编写代码的过程中,由于太长时间没用sin,cos函数忘了是用弧度为单位,汗呀 下面把代码贴出来 /* * 圆周运动动画 * */ ...

  8. Thread详解

    具体可参考:Java并发编程:Thread类的使用,这里对线程状态的转换及主要函数做一下补充. 一.线程状态转换图 注意: 阻塞状态是线程阻塞在synchronized代码块时的状态,而阻塞在Lock ...

  9. wikioi1369 xth 砍树

    题目描述 Description 在一个凉爽的夏夜,xth 和 rabbit 来到花园里砍树.为啥米要砍树呢?是这样滴, 小菜儿的儿子窄森要出生了.Xth这个做伯伯的自然要做点什么.于是他决定带着 r ...

  10. linux svn用法

    创建一个版本库.项目目录. 创建一个版本库: svnadmin create ~/SVNTestRepo 创建一个项目目录: svn mkdir file:///home/lsf/SVNTestRep ...