|
>1 佐藤 左のようなものを下からならべるには、
>2 伊藤 C言語では、どのようにしたらよいので
>3 鈴木 しょうか?
>4 加藤
>5 渡辺
>6 菊池
>7 平塚
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
static char buf[1024];
while (fgets(buf, sizeof buf, stdin)) {
char *p = strdup(buf);
if (p == NULL) {
fprintf(stderr, "out of memory\n");
exit(1);
}
main();
fputs(p, stdout);
}
return 0;
}
このプログラム revline.c とし、
これをコンパイルしてできたものを revline.exe とし、
逆順に並べ替えたいデータのファイルを data.txt とすると、
revline <data.txt
で、並べ替えたデータが表示されます。
revline <data.txt >result.txt
で、並べ替えたデータをファイルにすることもできます。
|