您的位置:首页 > 其它

HDU 1020 - Encoding

2015-07-22 11:20 483 查看

HDU 1020 - Encoding

Easy Problems -_-||

Input:

AABBBCDDDD


Output:

2A3BC4D


To practice more and simple example of input and output, not exactly algorithm, just practice. ..



*. -> Using string (char array) may be better.

#include<iostream>
#include<cstdio>

using namespace std;

void fRead(char cPrevious) {
char a;
int t = 1;
while(true) {
scanf("%c", &a);
if(cPrevious == a)
t++;
else
break;
}
if(t == 1)
cout  << cPrevious;
else
cout << t << cPrevious;

if(a == '\n')
cout << endl;
else
fRead(a);
}
int main() {
int n;
char a;
scanf("%d", &n);
while(n--) {
scanf("%c", &a);
scanf("%c", &a);
fRead(a);
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: