小腿肌肉不一样怎么办:哪位编程高手能用C#帮我编一个猜字游戏?我要源代码

来源:百度文库 编辑:高校问答 时间:2024/04/29 04:11:32

猜数字的游戏其实很简单的。不管是人猜计算机想的,还是计算机猜人想的都不是很复杂的。

我有一个压大小的代码,是我以前写的。给你做参考吧~!

你要的程序我就不写了,写了估计对你用处也不大。因为我不会C#。

用C写的压大小的小程序- -

#include "stdio.h"
#include "stdlib.h"
#include "time.h"

void guess();

main()
{
printf("You have 10$.\n");
guess();
}

void guess()
{
int num=0,temp=0;
int m=10;
char c;
do
{
srand(time(NULL));
num=rand();
num=num%2+1;
printf("please press B or S:");
c=getche();
c=='b'?temp=1:(c=='s'?temp=2:exit(1));
if((temp==num)&&(temp==1)) m+=8;
if((temp==num)&&(temp==2)) m+=4;
if(temp!=num) m-=5;
printf("You have %d$\n",m);
}while((temp==1)||(temp==2));
}

我的程序是在tc2下编译的。

你试试吧~!