This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(void) | |
{ | |
int num; | |
char c; | |
printf("乱数の範囲を指定して下さい:"); | |
scanf("%d", &num); | |
while (1){ | |
printf("Enterを押すと乱数を生成します:\n"); | |
c = getchar(); | |
if (c == '\n'){ | |
printf("乱数:%d\n", rand() % num + 1); | |
} | |
else if (c == 'q'){ | |
printf("終了"); | |
break; | |
} | |
} | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MACの環境では \ が ¥ にの代わりになるので
\nの部分を¥nに書き換える必要があるかもしれません。