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;
}
|