2010年9月17日 星期五

ACM 11541 - Decoding

#include <stdio.h>
#include <ctype.h>
char str[400], ch;
int count;
int main()
{
int caseNum, i, j, k, isPut;
scanf("%d", &caseNum);
for (i = 1; i <= caseNum; i ++)
{
printf("Case %d: ", i);
scanf("%s", str);
for (j = 0; str[j]; j ++)
{
if (isalpha(str[j])) ch = str[j], isPut = 1, count = 0;
else if (isPut && isdigit(str[j]))
count = count * 10 + str[j] - '0';
if (isPut && str[j + 1] == '\0' || !isdigit(str[j + 1]) && count > 0)
{
while (count --)
printf("%c", ch);
isPut = 0;
}
}
printf("\n");
}
return 0;
}


回目錄
回首頁

沒有留言 :

張貼留言

Related Posts Plugin for WordPress, Blogger...