HDU 1020(字符串转码)
来源:互联网 发布:网络发展前景 编辑:程序博客网 时间:2024/06/05 04:12
#include <iostream>#include <cstdio>#include <algorithm>#include <string>#include <cstring> using namespace std;const int MAXN = 10000 + 10;/*关键 : 数值转字符时, 记得大于10的数要转化为字符串而非字符*/int main(){int T;scanf("%d", &T);for(int i=0; i<T; i++){int cnt = 1;char str[MAXN], newstr[MAXN];memset(newstr,0,sizeof(newstr));scanf("%s", str);char ch, oldch;ch = oldch = *str;for(int j=1, k=0; 1 ; j++){ch = str[j];if( ch==oldch ){cnt++;}else{if( cnt>1 ){char tmpstr[MAXN];memset(tmpstr,0,sizeof(tmpstr));sprintf(tmpstr, "%d", cnt);strcat(newstr, tmpstr);k += strlen(tmpstr);//newstr[k++] = cnt+'0';}newstr[k++] = oldch;oldch = ch;cnt = 1;}if( ch==0 ){newstr[k++] = 0;break;} }cout << newstr << endl;}return 0;}
0 0
- HDU 1020(字符串转码)
- hdu 1020 简单字符串
- HDU 1020 字符串编码
- HDU 1020 Encoding 字符串
- HDU--1020:Encoding (字符串)
- HDU 1020 Encoding (字符串处理)
- hdu 1020 Encoding 字符串处理
- hdu 1020 Encoding(字符串处理)
- HDU 1020 Encoding字符串编码
- hdu 1020 Encoding【字符串处理】
- HDU 1020 Encoding(字符串合并)
- HDU 1020 Encoding 字符串 水题
- HDU 1020 Encoding 字符串操作
- hdu字符串
- hdu 1020 简单的字符串处理
- HDU 1020 Encoding 控制字符串的输出
- 【HDU】(字符串)1020_Encoding C++解法
- hdu 2017 字符串统计
- HDU 1032(3n+1问题)
- 从零开始自学Swift(八)
- error C2719: "_Val": 具有__declspec(align('16'))的形参将不被对齐
- BitTorrent的DHT协议(译自官方版本)
- Centos 6.x/7.x yum安装php5.6.X(最新版)
- HDU 1020(字符串转码)
- new一个Object对象占用多少内存?
- vad in amr codec from 3gpp
- LeetCode 237 : Delete Node in a Linked List
- Objective-C,类簇详解Foundation框架中的类簇
- Android 单击事件的几种写法
- 自己在家怎样做服务器?
- xhr和跨域问题
- Spring 笔记