zoj 3406 Another Very Easy Task
March 19, 2013
zoj
This task is so easy that the description is omitted.
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
char a[100000];
int main(void){
#ifndef ONLINE_JUDGE
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
while (gets(a)){
int len = strlen(a); bool flag = false; int cnt = 0;
for (int i = 0; i < len; ++i){
cnt = 0; flag = false;
while (isalpha(a[i])){
if (!flag){
flag = true;
printf("%c", a[i]);
}
else cnt++;
i++;
}
if (cnt == 1) printf("%c", a[i-1]);
else if (cnt >= 2){printf("%d", cnt-1); printf("%c", a[i-1]);}
if (i < len) printf("%c", a[i]);
}
printf("\n");
}
return 0;
}
这道水题,纠结好久,唉,真是思维不严谨啊,以后输出字符类的输出的题目一定要输出到文件,不然哪里错了都看不出来,水题还这么卡,看来自己需要练练手速,还有做题的准确度。