void practice() { int get,i,count=0,win=0,lose=0; srand(time(0)); shouming(); while(1){ get=scan_data(); if(get==0) break; i=computer(); win_or_lose(get,i,&win,&lose,&count); } printf("胜利:%d盘\t失败:%d盘\t总盘数:%d盘\n",win,lose,count); }
/* print the victory message */ void win_or_lose_message(struct state *st, int k) { if (k%100 == 0) { switch(win_or_lose(st)) { case 1: attrset(A_BOLD | COLOR_PAIR(4)); mvaddstr(2 + st->grid.height, 31, "You are victorious!"); break; case -1: attrset(A_BOLD | COLOR_PAIR(2)); mvaddstr(2 + st->grid.height, 31, "You are defeated!"); break; default: ; } } }
void duizhanmoshi(struct user *p) { int get,i,count=0,win=0,lose=0; srand(time(0)); shouming(); while((win!=2)&&(lose!=2)){ get=scan_data(); i=computer(); win_or_lose(get,i,&win,&lose,&count); } printf("胜利:%d盘\t失败:%d盘\t总盘数:%d盘\n",win,lose,count); if(win==2) {printf("You win! \n");} else {printf("Sorry,you lose!!!\n");} printf("大侠,请留名:"); getchar(); gets(stu[N].name); stu[N].win=win; stu[N].count=count; save_data(&stu[N]); }