#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='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("gui win!!! \n"); break ; } if(cou==70) { printf("tui win!!! \n"); break ; } Sleep(1); } printf("2013914203"); printf("\n"); }总结:编程序时思维要跟上,敲键盘速度也要跟上。。。
![]()
![]()
共2条
1/1 1 跳转至页
C语言程序设计--龟兔赛跑
关键词: 龟兔赛跑 printfun count
共2条
1/1 1 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 28BYJ-48机械臂实现人脸跟随被打赏¥24元 | |
| 基于RK3506B的片温识读功能的实现被打赏¥25元 | |
| 【瑞萨RA8D1测评】基于FreeRTOS的lvgl移植教程被打赏¥29元 | |
| 电子价签墨水屏开发被打赏¥35元 | |
| 【Ozone】RTT 打印终端使用被打赏¥29元 | |
| BMS保护板绝缘检测功能-不平衡电桥技术绝缘电阻检测设计与实现被打赏¥34元 | |
| 给28BYJ-48三自由度机械臂加一个网页控制台被打赏¥32元 | |
| 用28BYJ-48电机从零搭一台三自由度机械臂被打赏¥33元 | |
| 【英飞凌开发经验】ModusToolbox配置EdgeTalk外设被打赏¥27元 | |
| 基于BQ76952PFBR的BMS保护板热插拔损坏的原因和处理措施被打赏¥32元 | |
我要赚赏金
