guaat2001

|
分享:
▲
我最後寫出來的結果,但是是黑箱作業~誰能幫我解決一下這問題 還有我是用unix寫的 老師規定的 好像沒辦法跑randmize這個函數 謝謝大家哦~^^
#include <stdio.h> #include <stdlib.h>
int main() { int a,player,computer,flag=0,winc=0,winp=0;
while(flag==0) { printf("plz enter the 1 to 3 bones to play the game;otherwise:exit\n"); scanf("%d",&a);
if(a>3) { exit(0); } if(a<1) { exit(0); } player=a+rand()%(5*a+1); computer=a+rand()%(5*a+1);
if(computer > player) { printf("computer is winer and win: %d point is %d\n",++winc,computer); } if(player > computer) { printf("player is winer and win: %d point is %d\n",++winp,player); } if(player == computer) { printf("Draw\n"); } if(winp==2) { flag=1; } if(winc==2) { flag=2; } if(flag==1) { printf("the winer is player"); } if(flag==2) { printf("the winer is computer "); } } return 0;
}
|