C/C++の宿題を片付けます 92代目
■ このスレッドは過去ログ倉庫に格納されています
0585デフォルトの名無しさん
2007/07/11(水) 00:40:49#include <stdio.h>
int main(int argc, char **argv)
{
char queue[3];
int c, n, qhead = 0, qtail = 0;
while ((c = getchar()) != EOF) {
queue[qtail] = c;
qtail = (qtail + 1) % 3;
if (qhead != qtail)
continue;
if (queue[(qhead + 1) % 3] == 0) {
c = queue[qhead];
n = queue[(qhead + 2) % 3];
while (n--) putchar(c);
qhead = qtail = 0;
} else {
putchar(queue[qhead]);
qhead = (qhead + 1) % 3;
}
}
while (qhead != qtail) {
putchar(queue[qhead]);
qhead = (qhead + 1) % 3;
}
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています