杭电 1020 Encoding
2017-11-26 21:12
357 查看
这道题很水,没看懂题目时觉得挺复杂的,又要输出数字又要输出字母。于是尝试分开输出然就成功通过了。
#include<iostream> #include <string> using namespace std; int main() { int m; cin >> m; while (m--) { char a[10000]; int b, n = 1; cin >> a; b = strlen(a); char tem; tem = a[0]; for (int i = 1; i < b; i++) { if (a[i] == tem) { n++; } else { if (n != 1) cout << n << tem; else cout << tem; n = 1; tem = a[i]; } } if (n != 1) cout << n << tem << endl; else cout << tem << endl; } return 0; }
相关文章推荐
- 杭电1020 之 Encoding
- 杭电Hd 1020 Encoding
- 杭电OJ1020 Encoding
- 杭电 1020 Encoding
- 杭电1020 Encoding
- 杭电ACM OJ 1020 Encoding 输入一串字符 判断每种字符个数 我犯了个错误定义数组长度的错误
- 杭电1020(Encoding)
- 杭电oj(java版)—— 1020 Encoding
- 杭电1020 Encoding
- 杭电acm 1020 Encoding
- 杭电ACM HDU 1020 Encoding
- 杭电1020-Encoding
- 杭电 HDU 1020 Encoding
- 杭电1020 Encoding
- 杭电ACM 1020 Encoding
- 杭电1020 Encoding
- 杭电acm1020 Encoding
- 杭电1020 ——Encoding
- 杭电1020 Encoding
- 杭电1020 Encoding (字符串处理)