HDU1020
2015-02-05 01:04
169 查看
用这种方法实现的代码好像在哪看过,但忘记了在哪了
/*vector_change----HDU1020*/ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define N 1010 #define LL long long #define debug(x) cout<<#x<<":"<<(x)<<endl; using namespace std; //15-2-5 int main() { int n; scanf("%d", &n); char ch1, ch2; int num = 1; getchar(); //吸收按回车 while( n-- ) { ch1 = getchar(); while( ch2 != '\n' ) //结束条件,遇到回车键 { ch2 = getchar(); if( ch2 == ch1 ) num++; else{ if(num>1) printf("%d%c", num, ch1); else printf("%c", ch1); num = 1; } ch1 = ch2; } ch2 = '0'; //ch2 会留下上次的'\n'所以要清空 printf("\n"); } return 0; }
相关文章推荐
- HDU 1020 Encoding 字符串
- HDU1020
- HDU 1020 — Encoding
- hdu 1020 Encoding
- HDU 1020 字符串编码
- HDU1020——Encoding
- http://acm.hdu.edu.cn/showproblem.php?pid=1020..
- hdu 1020 找规律
- hdu 1020 Encoding
- hdu1020 - Encoding
- HDU1020 Encoding
- hdu 1020
- ACM_HDU 1020 Encoding
- hdu 1020 encoding
- HDU 1020 Encoding
- HDU1020 - Encoding (模拟)
- hdu 1020
- hdu 1020 Encoding
- HDU 1020
- hdu 1020(模拟)