【#第一文档网# 导语】以下是®第一文档网的小编为您整理的《C语言小游戏代码》,欢迎阅读!
![小游戏,语言,代码](/static/wddqxz/img/rand/big_42.jpg)
#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