资源描述:
《c语言 猜数字游戏程序(c language guessing game program)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、c语言猜数字游戏程序(Clanguageguessinggameprogram)Theteacher'swords:***//cloudsLuoYutaostudentsalwaysmakesome/alittleprogramtotryaTheguessinggameauthorisstrivingtoimprovetheinginfutureIsendthefullversion,oh,verygood.#include"stdio.h""#include"conio.h""#include"dos.h""#include"stdlib.h""Voidmain(){IntZ,Z1,
2、IA,IB,Iindex,iindex1,I,Ag,i_1,i_2,easy,Xianshi;/**/variabledefinitionInti1[5],i2[5];Charyesno;Chooes:/*setGOTO*/Printf("pleasechooes:1fornomal2forhardpleaseinput1or2:");/**/tochoosethedifficultyScanf("%d",&easy);If(easy==1){Iindex1=20;}Else{If(easy==2){Iindex1=10;}Else{If(easy==520){(Shua)
3、;/**/callbrushsmallscreenfunctionPrintf("wahahahaaaaa....youchoose-=Crazy=-model!!!");Iindex1=5;Getch();}Else{(Shua);/**/callbrushsmallscreenfunctionPrintf("**erroy...pleaseinputagain...1or2:");Gotochooes;}}}For(iindex=0;iindex<10;/**/iindex++)forvariableassignment{I1[iindex]=0;I2[iindex
4、]=0;}Ia=0,ib=0,z=11;Iindex=0;Do/*1-9999randomnumber,up1-999,selectthenumberof*1000-9999{For(iindex=0;Iindex{z=random(100)*random(100);}/*randomnumber.I1[3]=z%10;/*therandomnumberisdividedinto4.I1[2]=z/10%10;I1[1]=z/100%10;I1[0]=z/1000%10;}While(z<1000
5、
6、i1[0]==i1[1]
7、
8、i1[0]==i1[2]
9、
10、i1[0]==i1[3]
11、
12、i
13、1[1]==i1[2]
14、
15、i1[1]==i1[3]
16、
17、i1)[2]==i1[3]
18、
19、i1[0]==0);/*judgeeachdigitisthesame,ifitistooutput.(Shua);/**/callbrushsmallscreenfunctionPrintf("Now!You!Have%dlifes!Game!Star!,iindex1!");/**/thestartofthegamePrintf("pleaseinput4numbers:");For(xianshi=10;iindex1>0;iindex1-=1,xianshi-=1)/*iindex1
20、decidedtotrythenumber.{do{Printf(*);Scanf("%d",&z1);I2[3]=z1%10;/*thegameplayerinputnumberseparatedinto4.I2[2]=z1/10%10;I2[1]=z1/100%10;i2[0]=z1/1000to10%;if
21、
22、z1z1(>of<1000
23、
24、i2[0]==[1],
25、
26、p2p2p2==[0],[2],
27、
28、[0]==p2p2p2
29、
30、[3][1]==[2]
31、
32、p2p2p2==[1],[3]
33、
34、[2]==p2p2p2
35、
36、[3],[0]==0)/*判断玩家输入数字是否每一位不同,是则重新输入
37、*/{调用刷小屏涵数shua();/**/printf("n**erroy,pleaseinputagain:ininin');continue;}else{break;}while(1)};/**/设置非0,使循环直到breakib=0;/*开始判断:数字正确,位置错误的个数(b)*/if(a[0]==p1+p2+ib(1));if(a[0]=i1=i2+ib+[2]);if(a[0]==p1+p2+ib)[3];if(a[1]=i1=i2+