C语言龟兔赛跑数据,C语言龟兔赛跑

#include

#include

#include

#include

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]='G';

}

if(number>=6 && number<=7)

{

count-=6;

if(count<0)

{

count=0;

}

printfun[count]='G';

}

if(number>=8 && number<=10)

{

count+=1;

if(count>70)

{

count=0;

}

printfun[count]='G';

}

if(number>=1 && number<=2)

{

cou+=0;

if(cou>70)

{

cou=0;

}

printfun[cou]='T';

}

if(number>=3 && number<=4)

{

cou+=9;

if(cou>70)

{

cou=0;

}

printfun[cou]='T';

}

if(cou==5)

{

cou-=12;

if(cou<0)

{

cou=0;

}

printfun[cou]='T';

}

if(number>=6 && number<=8)

{

cou+=1;

if(cou<70)

{

cou=0;

}

printfun[cou]='T';

}

if(number>=9 && number<=10)

{

cou-=2;

if(cou<0)

{

cou=0;

}

printfun[cou]='T';

}

if(count==cou)

{

printfun[count]='P';

}

printf("%s\n",printfun);

printf("\n");

if(count==70)

{

printf("Tortoise win!!!\n");

printf("2013304124 homework");

break;

}

if(cou==70)

{

printf("Rabbit win!!!\n");

break;

printf("2013304124 homework");

}

}

}

9a86716c88aaa9710b53586d1555f9de.png

004d806eefcecbfb41416bd0034cda2d.png

c54aec15cb937927e4214a736786c5c4.png

63106e7830345971bf6be0ab22492535.png

总结:敲了第一次,有挺多错误的,然后慢慢修改,不知为什么总是乌龟赢呢? 要慢慢研究研究

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值