Skip to content

Instantly share code, notes, and snippets.

@seka
Last active August 29, 2015 14:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#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);
}
@seka
Copy link
Author

seka commented Nov 25, 2014

MACの環境では \ が ¥ にの代わりになるので
\nの部分を¥nに書き換える必要があるかもしれません。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment