C语言小游戏代码

2022-07-11 20:10:13   第一文档网     [ 字体: ] [ 阅读: ] [ 文档下载 ]
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。下载word有问题请添加QQ:admin处理,感谢您的支持与谅解。点击这里给我发消息

#第一文档网# 导语】以下是®第一文档网的小编为您整理的《C语言小游戏代码》,欢迎阅读!
小游戏,语言,代码

#include #include #include void pass (int*charge));

void road (char*s,int*step,char count); void ouch (char*t,int a1,int a2); int wins (int count1,int count2); main () {char line [72];

int hare[11]={0,0,0,9,9,-12,1,1,1,-2,-2}; int tie[11]={0,3,3,3,3,3,-6,-6,1,1,1}; int i,b,c1=1,c2=1;

printf("bang!!!!!\n""andthay're off!!!!!\n"); while (! wins(c1 c2)){ srand (time (null)); for (b=0;b<=70;b++) line[b]=' '; line[71]='\0'; i=1+rand()%10; c1+=hare[i]; c2+=tie[i]; road (line,&c1,'h');


road (line,&c2,'t'); ouch(line,c1,c2); sleep(1); } getch(); return 0; }

void pass (int*charge) {if (*charge>70) *charge=70; else if (*charge<1) *charge=1; }

void rode (char*s,int*step,char count) {

pass (step); s[*step]=count; }

int wins(int count1,int count2) {if (count1==70){


printf("hare wins. yuch.\n"); return 1; }

else if(count2==70){

printf("tortoise wins!!! yay!!!\n"); return 1; }

else if (count1==count1&&count2==70){ printf("it's a tie.\n"); return 1; }return 0; }

void ouch(char*t,int a1,int a2) {

if (a1==a2&&a1!=70) printf("ouch!!!!!\n\n"); else

printf("%s\n\n",t);}




本文来源:https://www.dywdw.cn/3699a652f76527d3240c844769eae009581ba2cc.html

相关推荐
推荐阅读