#99 Article 972 Posted at 1995/12/04 06:52:58 by 愛子は由里さ (MAP3877) [SAHOU.1]
Subject: Re:*6 プログラミングお作法の話 /946 ... /941 /940
では、わたしのですぅ。
#MEXさんや、Mick'nさんのと似たようなのになってしまいました。
エディターはemacs系をつかっています。(DemacsとFreemacsです)
Tabは8で、indentは4です。BSD風なindent方法です。
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
;(setq c-label-offset 0)
;;ラベルはあまりつかわないので、defaultの-2のままにしてます。
----------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
void usage(void)
{
fprintf(stderr, "Usage: prog num\n");
}
void repeat_print(int n, const char *str)
{
while (--n >= 0) {
printf("%s", str);
}
printf("\n");
}
int main(int argc, char **argv)
{
int num, i;
if (argc < 2) {
usage();
return 1;
}
if ((num = atoi(argv[1])) <= 0) {
usage();
return 1;
}
for (i = 1; i <= num; i++) {
if (i == 3 || i == 5 || i == num) {
repeat_print(i, "にゃん");
} else {
printf("%d\n", i);
}
}
return 0;
}
----------------------------------------------------------------
反省:repeat_printの中に"\n"をいれないほうがよかったな、とあとで
思った。でも、書きかえなかったけど。
whileループは、LSIC86で効率がいい(つもり)です(^^;)。
#あんまり意味がないかも
愛子は由里さ(ゆあさ あきひろ)