My student number: s144099 Random numbers: 91 and 7 --> OK! ----------------------------- |
表示においては,最初の行に学生番号,最後にはハイフンによる線を出力するようにしてください.また,必ず解答用紙を使用し,解答用紙には学生番号と名前を記入してください.
変数は2つ使用します.乱数の作り方に注意してください.
/* ************************************************** */ /* */ /* プログラミング入門 情報科学演習C7 */ /* 小テスト */ /* 2014.10.27 */ /* */ /* ************************************************** */ /* */ /* 学生番号: */ /* */ /* 氏名: */ /* */ /* ************************************************** */ /* */ /* この行以降に解答のプログラムを書くこと */ #include <stdio.h> #include <stdlib.h> #include <time.h> main() { srand((unsigned) time(NULL)); int m, n; m = rand() % 90 + 10; n = rand() % 9 + 1; printf("My student number: s144099\n\n"); printf("Random numbers: %d and %d --> ", m, n); if(m%n==0) printf("OK!"); else printf("NG"); printf("\n\n-----------------------------\n"); return(0); } |