谁有C语言课程设计 猜数字游戏编程及解释 要有规则XAXBR的那种

来源:百度知道 编辑:UC知道 时间:2024/06/28 16:24:05
我们正在学习C语言编程,急需一个猜数字游戏,需要的是有程序源代码,有代码注释,
猜数字游戏其代码如下:谁能帮忙解释一下

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
int f1[4],f2[4],m=0,n=0,k,i,j;
char f3[4],ch,*s[]={" GUESS THE DIGITAL GAME"," FIGURE INPUT | RESULT",
"GOOG LUCK.PLAY AGAIN(y/n)"," BAD LUCK.PLAY AGAIN(y/n)","RIGHT NUMBERS:" };
wd1()
{
textbackground(6);
clrscr();
window(25,3,55,4);
textbackground(1);
textcolor(12);
clrscr();
cputs(s[0]);
window(25,5,55,6);
textbackground(2);
textcolor(15);
clrscr();
cputs(s[1]);
window(25,6,55,16);
textbackground(4);
clrscr();
window(32,6,50,16);
textbackground(4);
textcolor(15);
clrscr();
}
wd2()
{
window(25,18,55,19);
textbackground(2);

#i nclude <stdlib.h>
#i nclude <stdio.h>
#i nclude <time.h>
#i nclude <conio.h>

int times=1;
/*This function makes an array of four differrent numbers.*/
int *make_ans(int ans[])
{
int i,used[10]={0},*t=ans;
static int change_seed=0;
srand(time(0)+change_seed);
if (change_seed<100)change_seed++;else change_seed=0;
for(i=0; i<4; i++)
{
do
{
ans[i]=rand() % 10;
}while(used[ans[i]]);
used[ans[i]]=1;
}
printf("Game Start!\n");
return (t);
}
/*This function gets a num from keyboard and does not echo to the screen.*/
int get_num()
{
char n;
do
{
n=getch();
}
while (n<'0'||n>'9');
printf("%d",n-'0');
return n-'0';