求一个用VC++C语言写的小游戏。

# include & ltstdio.h & gt

# include & lttime.h & gt

# include & ltstdlib.h & gt

int main(void)

{

int random();

int mopai(int shan);

int your chusha(int shan);

int i,xingcan=0,temp,choice

int yoursha=0,your shan = 0;

int itssha=0,its shan = 0;

int yourhp=4,its HP = 4;

Printf("三国杀简化版:\ n ");

Printf("开始游戏:\ n ");

srand((无符号)时间(空));

for(I = 1;我& lt=4;i++)

{

random();//random()方法可以返回0到1之间的随机数。

如果(!random())

your shan+= 1;

else your sha+= 1;

}

for(I = 1;我& lt=4;i++)

{

random();

如果(!random())

its shan+= 1;

else its sha+= 1;

}

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("计算机之手:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

while(your HP & amp;& ampitshp)

{

printf(" \ n您的操作开始:\ n ");

printf(" \ n接触阶段:\ n ");

temp=mopai(星灿);

your shan+= temp;

your sha+=(2-temp);

xing can = 0;

Printf("你的手:杀死%d,闪现%d \n ",yoursha,Your shan);

printf(" \ n按任意键继续\ n ");

getch();

系统(“cls”);

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("计算机之手:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

Printf("\n播放阶段:\ n ");

Printf("请选择:\ n ");

Printf("1。杀死2。fold \ n ");

while(1)

{

scanf("%d ",& amp选择);

如果(选择!=1。& amp选择!=2)

Printf("输入错误,请重新输入\ n ");

else break

}

if(choice==1)

{

如果(你的莎)

{

your sha-= 1;

if(your chusha(it shan))

its shan-= 1;

其他

{

its HP-= 1;

}

}

Else printf("你没杀,请折叠\ n ");

}

如果(!itshp)

打破;

printf(" \ n按任意键继续\ n ");

getch();

系统(“cls”);

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("计算机之手:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

Printf("丢弃阶段:\ n ");

while(your sha+your shan-your HP & gt;0)

{

Printf("需要弃牌%d张,请逐一弃牌:\n ",your sha+your shan-your HP);

Printf("1。弃一杀二。丢弃一个flash \ n ");

while(1)

{

scanf("%d ",& amp选择);

如果(选择!=1。& amp选择!=2)

Printf("输入错误,请重新输入\ n ");

else break

}

开关(选择)

{

案例1:

{

如果(你的莎)

your sha-= 1;

Else printf("你没杀,请重新选择\ n ");

打破;

}

案例二:

{

如果(你的山)

your shan-= 1;

Else printf("你没闪,请重新选择\ n ");

打破;

}

}

}

Printf("你的行动结束了。\ n ");

printf(" \ n按任意键继续\ n ");

getch();

系统(“cls”);

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("计算机之手:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

Printf("计算机操作开始:\ n ");

Printf("摸卡阶段:\ n ");

temp=mopai(星灿);

its shan+= temp;

its sha+=(2-temp);

xing can = 0;

Printf("电脑手数:%d \n ",its sha+its shan);

printf(" \ n按任意键继续\ n ");

getch();

系统(“cls”);

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("计算机之手:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

Printf("播放阶段:\ n ");

如果(itssha)

{

its sha-= 1;

printf(" kill \ n ");

Printf("电脑杀了你,请闪\ n ");

Printf("1。OK 2。取消\ n ");

while(1)

{

scanf("%d ",& amp选择);

如果(选择!=1。& amp选择!=2){

Printf("输入错误,请重新输入\ n ");

系统(“cls”);

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("计算机之手:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

}

else break

}

开关(选择)

{

案例1:

{

如果(你的山)

{

your shan-= 1;

printf(" flash \ n ");

打破;

}

Else printf("你没闪\ n ");

}

案例二:

{

your HP-= 1;

Printf("电脑对你有伤害\ n ");

}

}

}

如果(!yourhp)

打破;

Printf("电脑手数:%d \n ",its sha+its shan);

Printf("丢弃阶段:\ n ");

if(its sha+its shan-its HP & gt;0)

{

if(its HP & gt;itsshan)

{

Printf("计算机丢弃了%d份副本\n ",its sha+its shan-its HP);

its sha-=(its sha+its shan-its HP);

}

其他

{

Printf("电脑杀死%d,闪现%d \n ",itssha,its shan-its HP);

its sha = 0;

itsshan = itshp

}

}

Printf("电脑的动作结束了。\ n ");

printf(" \ n按任意键继续\ n ");

getch();

系统(“cls”);

Printf("你的手:杀死%d张牌,闪现%d张牌\t ",yoursha,Your shan);

Printf("电脑手数:%d \n ",its sha+its shan);

Printf("你的体力:%d\t ",Your HP);

Printf("计算机物理强度:%d\n ",its HP);

}

如果(!yourhp)

Printf("可惜电脑打败你了\ n ");

Else printf("恭喜你,你打败了电脑\ n ");

Printf("游戏结束,请下次再来!\ n ");

printf(" \ n按任意键退出。);

getch();

返回0;

}

int random()

{

返回rand()% 3;

}

int mopai(int shan)

{

int I;

srand((无符号)时间(空));

for(I = 1;我& lt=2;i++)

{

random();

如果(!random())

山+= 1;

}

归山;

}

int yourchusha(int shan)

{

printf(" kill ");

如果(山)

{

printf(" flash \ n ");

返回1;

}

其他

{

Printf("你对电脑造成了一些伤害\ n ");

返回0;

}

}