第2个回答 2007-09-20
#include<stdio.h>
#include<time.h>
void main()
{
int computer;
int player;
int tmp;
char *v[3]={"shitou","jiandao","bu"};
char ch;
srand(time(NULL));
while(1)
{
system("cls");/**/
computer=rand()%3;
printf("\n(0)shitou\t(1)jiandao\t(2)bu\n");
printf("Please input your choice:");
scanf("%d", &player);
if(player<0 || player>2) continue;
printf("\nComputer:\t%s",v[computer]);
printf("\nYou:\t\t%s\n\n",v[player]);
tmp = player - computer;
if(tmp == 1 || tmp == -2) printf("Computer Win!\n\n");
if(tmp == -1 || tmp == 2) printf("You Win!\n\n");
printf("\n****************************************************");
printf("\npress 'n' or 'N' to quit! any other key to continue!");
ch =getch();
if(ch=='n' || ch=='N') return;
}
}