Encoding 字符串的简单处理 我的开始
来源:互联网 发布:thumbdata4 软件 编辑:程序博客网 时间:2024/06/05 09:06
Encoding
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluDescription
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 100.
Output
For each test case, output the encoded string in a line.
Sample Input
2
ABC
ABBCCC
我对于这个题目有一种情节,从我大一接触这个题目,用了两个多小时都
做不出来,到今天只用了15分钟就搞定了,我想说这是一个过程,我在逐
渐成长着。
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int i,j,t,y; char s[104]; scanf("%d",&y); while(y--) { //getchar(); scanf("%s",s); int len=strlen(s); //printf("%d\n",len); int q; for(i=0;i<len;i++) { t=0; //printf("%c",s[i]); for(j=i+1;j<len;j++) { if(s[i]!=s[j]) { break; } else { t++; i++; } } // i=q-1; if(t==0) printf("%c",s[i]); else printf("%d%c",t+1,s[i]); } printf("\n"); } return 0;}
- Encoding 字符串的简单处理 我的开始
- hdu 2265 Encoding The Diary (基础的字符串处理,巨简单)
- 我的字符串处理
- 简单字符串的处理
- 字符串的简单处理
- 字符串的简单处理
- 简单的字符串处理
- 简单的字符串处理
- 字符串的简单处理~~
- Encoding(字符串处理)
- 开始我的图像处理学习
- 字符串的简单处理 nyoj525
- hdoj1020简单的字符串处理
- C#简单的字符串处理
- 字符串String的 简单处理
- HDU 1020 Encoding (字符串处理)
- hdu 1020 Encoding 字符串处理
- hdu 1020 Encoding(字符串处理)
- 把由十六进制数字组成的字符串转换为与之等价的整数值
- Sql语句中时间数据格式的转变
- v8 ---javascript engine & chrome engine
- 过滤器和拦截器的比较及未登录用户权限限制的实现
- string 模拟之-big three
- Encoding 字符串的简单处理 我的开始
- [PHP]进阶教程:PHP中Cookies与Sessions的创建和使用
- Linux之V4L2基础编程
- Core Animation编程指南
- jfreechart 1.0.13中文乱码问题的解决
- JSP自定义标签
- java MD5
- python聊天服务器实现
- 局部加权回归