HDOJ 1020 一次AC代码
来源:互联网 发布:英语听力口语软件 编辑:程序博客网 时间:2024/05/16 18:11
/*****************************************************************************
Baichenjia 2013.8.25
HD1020 Encoding
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
*****************************************************************************/
#include <iostream>
#include <string>
using namespace std;
int main()
{
char str[10000];
int n;
int i,j;
cin>>n;
while(n --)
{
char strtemp[10000];
memset(str,0,10000);
memset(strtemp,0,10000);
cin>>str;
for(i = 0,j = 1;;i ++)
{
strtemp[j] = str[i];
if((strtemp[j] == strtemp[j- 1]) || (strtemp[j - 1] == 0))
{
j ++;
}
else if((strtemp[j] != strtemp[j- 1]) || (i == strlen(str)))
{
if(j == 2)
cout<<strtemp[j - 1];
else
cout<<j - 1<<strtemp[j - 1];
if(i == strlen(str))
break;
i = i - 1;
j = 1;
memset(strtemp,0,10000);
}
else
{}
}
cout<<endl;
}
return 0;
}
- HDOJ 1020 一次AC代码
- HDOJ 1005 值得注意的解题 一次AC~
- uva10344 一次AC
- uva705一次AC
- uva301重做,一次ac!
- 非一次ac
- 一次ac题号
- hdoj 3065 ac自动机
- HDOJ 1219 AC ME
- 【AC自动机】 HDOJ 2243
- hdoj 1219 AC Me
- AC Me hdoj 1219
- hdoj 2006 ac
- HDOJ 2896 AC自动机
- AC代码
- 【HDU2780 - Su-Su-Sudoku】 解题报告+思路+代码,差点一次AC T^T
- 继续Node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ
- poj3083 dfs+bfs一次ac
- 将一数组乱序排列的三种方法
- c++接口定义及实现举例
- HDOJ 2063 二分图匹配
- android应用完全退出的多种方式
- hibernate 的cache管理
- HDOJ 1020 一次AC代码
- error: 'for' loop initial declarations are only allowed in C99 mode 的原因及解决办法
- 图形学_画线算法(DDA、Bresenham)
- 图形学_圆的扫描转换
- 图形学_椭圆扫描转换_中点椭圆算法
- iOS动画特效
- 图形学_多边形扫描转换_边界标志算法
- 图形学_二维图形的剪裁_Sutherland-Hodgeman_Cohen—Sutherland
- HDOJ1009