纯c语言编写的打字游戏代码.docx

上传人:b****0 文档编号:12571072 上传时间:2023-04-20 格式:DOCX 页数:12 大小:15.55KB
下载 相关 举报
纯c语言编写的打字游戏代码.docx_第1页
第1页 / 共12页
纯c语言编写的打字游戏代码.docx_第2页
第2页 / 共12页
纯c语言编写的打字游戏代码.docx_第3页
第3页 / 共12页
纯c语言编写的打字游戏代码.docx_第4页
第4页 / 共12页
纯c语言编写的打字游戏代码.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

纯c语言编写的打字游戏代码.docx

《纯c语言编写的打字游戏代码.docx》由会员分享,可在线阅读,更多相关《纯c语言编写的打字游戏代码.docx(12页珍藏版)》请在冰豆网上搜索。

纯c语言编写的打字游戏代码.docx

纯c语言编写的打字游戏代码

xx信息科技大学

软件工程1301SHERO组

#include

#include

#include

#include

#include

voidfunc();

voidfun();

voidfu();

intk=0,num;

voidmain(){intchoice,choice1;

floatresult;

system("color5A");

printf("开始游戏:

1结束:

0\n");

scanf("%d",&choice);

do{

switch(choice){case1:

printf("请选择字母【7】数字【8】数字+字母【9】");

scanf("%d",&choice1);

switch(choice1){case7:

func();break;

case8:

fun();break;

case9:

fu();break;}system("cls");

printf("\n\n\n\n\n\n\n\n\n\n您成功地击落%d个字母!

",k);

printf("\n您有%d个字母未击落!

",num-k);result=(float)k/num;

printf("\n您的准确率为%.2f!

",result);break;

case0:

exit

(1);break;

default:

system("cls");

printf("指令有误!

请检查指令。

\n");

getchar();}printf("\n\n\n\n\n\n\n继续游戏:

1

scanf("%d",&choice);

}while

(1);}/***************字母模块*****************/

voidfunc(){inta[25][80];

inti,l,j,m=0,n=0,t,t1,temp,c=0;

intsure,sure1=0,dif,N;

do{

do

{system("cls");

printf("\n请选择难度等级:

困难:

1普通:

2结束:

0

简单:

3\n");

");

scanf("%d",&dif);

if(dif!

=1&&dif!

=2&&dif!

=3)

{printf("\n指令有误,按任意键继续!

");

getchar();}else

sure1=1;

}while(sure1!

=1);

if(dif==1)

N=10;

if(dif==2)

N=500;

if(dif==3)

N=2000;

printf("\n请输入字母个数:

");

scanf("%d",&num);

switch(dif){case1:

printf("\n你选择了困难等级,%d个字母进行练习。

",num);break;case2:

printf("\n你选择了普通等级,%d个字母进行练习。

",num);break;case3:

printf("\n你选择了简单等级,%d个字母进行练习。

",num);break;}

printf("\n\n确定请按1,重新选择请按0");

scanf("%d",&sure);

system("cls");

}while(sure!

=1);

printf("\n\n\n\n\n\n\n\n\n\n按任意键开始游戏!

\n");getch();/*头文件为#include*/

system("cls");

for(i=0;i<25;i++)/*赋值为空格*/

for(j=0;j<80;j++)

a[i][j]=32;

system("cls");

srand((unsigned)time(NULL));

a[0][rand()%80+1]=(rand()%26+65);

for(t=0;t0;i--)

for(j=80;j>0;j--)

printf("%c",a[i][j]);

_sleep(N);/*时间延迟,用来控制难度*/

m=0;

while(m<=22){for(l=0;l<80;l++){temp=a[m+1][l];

a[m+1][l]=a[m][l];

a[m][l]=temp;}m++;}if(!

kbhit())

printf("");

else{charc=getch();

for(i=0;i<25;i++)

for(j=0;j<80;j++)

if(c==27)

exit

(1);

elseif(a[i][j]==c-32){a[i][j]=32;

putchar('\a');

k++;}}

system("cls");

/*以下是最后一个字母出现以后所执行的*/

if(t==num-1)

{for(t1=0;t1<23;t1++){for(i=24;i>0;i--)

for(j=80;j>0;j--)

printf("%c",a[i][j]);

_sleep(N);/*时间延迟,用来控制难度*/

m=0;

while(m<=22){for(l=0;l<80;l++){if(m

a[m][l]=32;

temp=a[m][l];

a[m][l]=a[m+1][l];

a[m+1][l]=temp;}m++;}if(!

kbhit())

printf("");

else{charc=getch();

for(i=0;i<25;i++)

for(j=0;j<80;j++)

if(c==27)

exit

(1);

elseif(a[i][j]==c-32){a[i][j]=32;

putchar('\a');

k++;}}

system("cls");}}

/*以上是最后一个字母出现之后运行的*/

a[0][rand()%80+1]=(rand()%26+65);}}

/***************数字模块******************/

voidfun(){inta[25][80];

inti,l,j,m=0,n=0,t,t1,temp,c=0;

intsure,sure1=0,dif,N;

do{

do

{system("cls");

printf("\n请选择难度等级:

困难:

1普通:

2简单:

3");

scanf("%d",&dif);

if(dif!

=1&&dif!

=2&&dif!

=3)

{printf("\n指令有误,按任意键继续!

");

getchar();}else

sure1=1;

}while(sure1!

=1);

if(dif==1)

N=10;

if(dif==2)

N=500;

if(dif==3)

N=2000;

printf("\n请输入数字个数:

");

scanf("%d",&num);

switch(dif){case1:

printf("\n你选择了困难等级,%d个数字进行练习。

",num);break;case2:

printf("\n你选择了普通等级,%d个数字进行练习。

",num);break;case3:

printf("\n你选择了简单等级,%d个数字进行练习。

",num);break;}

printf("\n\n确定请按1,重新选择请按0");

scanf("%d",&sure);

system("cls");

}while(sure!

=1);

printf("\n\n\n\n\n\n\n\n\n\n按任意键开始游戏!

\n");getch();/*头文件为#include*/

system("cls");

for(i=0;i<25;i++)/*赋值为空格*/

for(j=0;j<80;j++)

a[i][j]=32;

system("cls");

srand((unsigned)time(NULL));

a[0][rand()%80+1]=(rand()%10+48);

system("cls");

for(t=0;t0;i--)

for(j=80;j>0;j--)

printf("%c",a[i][j]);

_sleep(N);/*时间延迟,用来控制难度*/

m=0;

while(m<=22){for(l=0;l<80;l++){temp=a[m+1][l];

a[m+1][l]=a[m][l];

a[m][l]=temp;}m++;}if(!

kbhit())

printf("");

else{charc=getch();

for(i=0;i<25;i++)

for(j=0;j<80;j++)

if(c==27)

exit

(1);

elseif(a[i][j]==c){a[i][j]=32;

putchar('\a');

k++;}}

system("cls");

/*以下是最后一个字母出现以后所执行的*/

if(t==num-1)

{for(t1=0;t1<23;t1++){for(i=24;i>0;i--)

for(j=80;j>0;j--)

printf("%c",a[i][j]);

_sleep(N);/*时间延迟,用来控制难度*/

m=0;

while(m<=22){for(l=0;l<80;l++){if(m

a[m][l]=32;

temp=a[m][l];

a[m][l]=a[m+1][l];

a[m+1][l]=temp;}m++;}if(!

kbhit())

printf("");

else{charc=getch();

for(i=0;i<25;i++)

for(j=0;j<80;j++)

if(c==27)

exit

(1);

elseif(a[i][j]==c){a[i][j]=32;

putchar('\a');

k++;}}

system("cls");}}

/*以上是最后一个字母出现之后运行的*/

a[0][rand()%80+1]=(rand()%10+48);}}

/*****************数字+字母模块******************/

voidfu(){inta[25][80];

inti,l,j,m=0,n=0,t,t1,temp,c=0;

intsure,sure1=0,dif,N,NO;

do{

do

{system("cls");

printf("\n请选择难度等级:

困难:

1普通:

2

scanf("%d",&dif);

if(dif!

=1&&dif!

=2&&dif!

=3)

{printf("\n指令有误,按任意键继续!

");

getchar();}else

sure1=1;

}while(sure1!

=1);

if(dif==1)

N=10;

if(dif==2)

N=500;

if(dif==3)

N=2000;简单:

3");

printf("\n请输入个数:

");

scanf("%d",&num);

switch(dif){case1:

printf("\n你选择了困难等级,%d个字进行练习。

",num);break;

case2:

printf("\n你选择了普通等级,%d个字进行练习。

",num);break;

case3:

printf("\n你选择了简单等级,%d个字进行练习。

",num);break;}printf("\n\n确定请按1,重新选择请按0

scanf("%d",&sure);

system("cls");

}while(sure!

=1);

printf("\n\n\n\n\n\n\n\n\n\n

getch();/*头文件为#include*/

system("cls");

for(i=0;i<25;i++)/*赋值为空格*/

for(j=0;j<80;j++)

a[i][j]=32;

system("cls");

srand((unsigned)time(NULL));

NO=rand()%2;

switch(NO){case0:

a[0][rand()%80+1]=(rand()%26+65);break;

case1:

a[0][rand()%80+1]=(rand()%10+48);break;}for(t=0;t

按任意键开始游戏!

\n");{for(i=24;i>0;i--)

for(j=80;j>0;j--)

printf("%c",a[i][j]);

_sleep(N);/*时间延迟,用来控制难度*/

m=0;

while(m<=22){for(l=0;l<80;l++){temp=a[m+1][l];

a[m+1][l]=a[m][l];

a[m][l]=temp;}m++;}if(!

kbhit())

printf("");

else{charc=getch();

for(i=0;i<25;i++)

for(j=0;j<80;j++)

if(c==27)

exit

(1);

elseif(a[i][j]==c-32){a[i][j]=32;

putchar('\a');

k++;}}

system("cls");

/*以下是最后一个字母出现以后所执行的*/

if(t==num-1)

{for(t1=0;t1<23;t1++){for(i=24;i>0;i--)

for(j=80;j>0;j--)

printf("%c",a[i][j]);

_sleep(N);/*时间延迟,用来控制难度*/

m=0;

while(m<=22){for(l=0;l<80;l++){if(m

a[m][l]=32;

temp=a[m][l];

a[m][l]=a[m+1][l];

a[m+1][l]=temp;}m++;}if(!

kbhit())

printf("");

}}}else{charc=getch();

for(i=0;i<25;i++)

for(j=0;j<80;j++)

if(c==27)

exit

(1);

elseif(a[i][j]==c){a[i][j]=32;

putchar('\a');

k++;}elseif(a[i][j]==c-32){a[i][j]=32;

putchar('\a');

k++;}}

system("cls");}/*以上是最后一个字母出现之后运行的*/

a[0][rand()%80+1]=(rand()%26+65);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1