96 is a multiple of 3. |
のように表示し,倍数で無いときには例えば,
90 is not a multiple of 4. |
のように表示するプログラムを作成せよ.いつものように,最初に学生番号を出 力し,最後にハイフンによるラインを出力することも忘れないように注意するこ と.
My student number: s114099 53 is not a multiple of 7. ----------------------------------- |
/* ************************************************** */ /* */ /* 情報科学演習 C6 C7 */ /* レポート課題 */ /* 2011.11.07 */ /* */ /* ************************************************** */ /* */ /* 学生番号: */ /* */ /* 氏名: */ /* */ /* ************************************************** */ /* */ /* この行以降に解答のプログラムを書くこと */ #include <stdio.h> #include <stdlib.h> #include <time.h> main() { srand((unsigned) time(NULL)); int m, n; m = rand() % 90 + 10; n = rand() % 8 + 2; printf("My student number: s114099\n\n"); printf("%d is ", m); if(m % n != 0) printf("not "); printf("a multiple of %d.\n", n); printf("\n-----------------------------------\n\n"); return(0); } |