#include "stdio.h" #include<stdlib.h> #include<time.h> #include<Windows.h> void guitu(void); main() { srand(time(NULL)); guitu(); return 0; } void guitu() { int j,count=0,cou=0,number; char printfun[71]; while(1) { for(j=0;j<70;j++) { printfun[j]=' '; printfun[70]='|'; } number=rand()%10+1; printf("\n"); if(number>=1&&number<=5) { count+=3; if(count>70) count=0; printfun[count]='T'; } if(number>=6&&number<=7) { count-=6; if(count<0) count=0; printfun[count]='T'; } if(number>=8&&number<=10) { count+=1; if(count>70) count=0; printfun[count]='T'; } if(number>=1&&number<=2) { cou+=0; if(cou>70) cou=0; printfun[cou]='G'; } if(number>=3&&number<=4) { cou+=9; if(cou>70) cou=0; printfun[cou]='G'; } if(cou==5) { cou-=12; if(cou<0) cou=0; printfun[cou]='G'; } if(number>6&&number<=8) { cou+=1; if(cou<70) cou=0; printfun[cou]='G'; } if(number>=9&&number<=10) { cou-=2; if(cou<0) cou=0; printfun[cou]='G'; } if(count==cou) printfun[count]='P'; printf("%s\n",printfun); printf("\n"); if(count==70) { printf("tu win!!!\n"); break; } if(cou==70) { printf("gui win!!!\n"); break; } } printf("\n"); printf("ID:2013304101\n"); }
总结:
(1)打程序的时候,要注意很多细节,比如括号和分号,虽然这在修改中很容易就看出来,但是要养 成好的 习惯。
(2)在运行的时候,我发现运行很多次,都是“gui win”,应该是程序有偏向吧,我看得不太懂,所以就只改了G,T,gui,tu,来让“tu win”。