You win \(^o^)/ You lose (;_;) Draw (-_-) | |
またじゃんけんの手の表記は Gu, Choki, Pa の3種類で,結果の表示は最終的には以下のように,学生番号とハイフンライン も忘れずに表示させること.
My student number: s114099 You: Gu Computer: Choki You win \(^o^)/ ----------------------------------- |
/* ************************************************** */ /* */ /* 情報科学演習 C6 C7 */ /* レポート課題 */ /* 2011.11.14 */ /* */ /* ************************************************** */ /* */ /* 学生番号: */ /* */ /* 氏名: */ /* */ /* ************************************************** */ /* */ /* この行以降に解答のプログラムを書くこと */ #include <stdio.h> #include <stdlib.h> #include <time.h> main() { srand((unsigned) time(NULL)); int h1, h2, judge; h1 = rand() % 3; h2 = rand() % 3 + 3; judge = (h2 - h1) % 3; printf("My student number: s114099\n\nYou: "); if(h1==0) printf(" Gu\n"); else if(h1==1) printf("Choki\n"); else printf(" Pa\n"); printf("Computer: "); if(h2==3) printf(" Gu\n"); else if(h2==4) printf("Choki\n"); else printf(" Pa\n"); if(judge==0) printf("Draw (-_-)\n"); else if(judge==1) printf("You win \\(^o^)/\n"); else printf("You lose (;_;)\n"); printf("\n-----------------------------------\n\n"); return(0); } |