电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

纯c语言编写的打字游戏VIP免费

纯c语言编写的打字游戏_第1页
1/6
纯c语言编写的打字游戏_第2页
2/6
纯c语言编写的打字游戏_第3页
3/6
// 纯c 语言编写的打字游戏 //华北电力大学 计算0903 曹建伟作品 #include #include #include #include #include void func(); int k=0,num; void main() { int choice ; float result; printf("开始游戏: 1 结束: 0 \n"); scanf("%d",&choice); do{ switch (choice) { case 1: func(); 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; case 0: exit(1);break; default : system("cls"); printf("指令有误!请检查指令。\n"); getchar(); } printf("\n\n\n\n\n\n\n 继续游戏: 1 结束: 0 \n"); scanf("%d",&choice); } while (1); } void func() { int a[25][80]; int i,l,j,m=0,n=0,t,t1,temp,c=0; int sure,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=1; if(dif==2) N=500; if(dif==3) N=20000; printf("\n 请输入字母个数: "); scanf("%d",&num); switch (dif) { case 1: printf("\n 你选择了困难等级,%d 个字母进行练习。",num);break; case 2: printf("\n 你选择了普通等级,%d 个字母进行练习。",num);break; case 3: 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 { char c = getch(); for(i=0;i<25;i++) for(j=0;j<80;j++) if(c==27) exit(1); else if (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

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

纯c语言编写的打字游戏

确认删除?
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群