#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 跳转至页
回复
有奖活动 | |
---|---|
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
【有奖活动】智能可穿戴设备AR/VR如何引领科技新潮流! | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
【有奖活动】震撼来袭!这场直播将直击工程师的心灵! |
打赏帖 | |
---|---|
如何实现基于NXPiMX.RT1021的BH1730采集被打赏50分 | |
【换取手持数字示波器】AHT10温度检测分享被打赏40分 | |
【换取手持数字示波器】ACM32F070开发板点亮LCD屏和触控按键,串口,ADC被打赏40分 | |
【换取手持数字示波器】ACM32F070LCD屏和触控按键功驱动蜂鸣器分享被打赏40分 | |
【换取手持数字示波器】国民技术PWM功能知识分享被打赏40分 | |
【换取手持数字示波器】放大器运放知识分享被打赏40分 | |
【分享评测,赢取加热台】+开关电源AC输入知识分享被打赏30分 | |
【换取手持数字示波器】N32G430点亮数码管与串口打印、ADC被打赏40分 | |
老胖子聊电路--分析一个反馈电路被打赏50分 | |
【换取手持数字示波器】+点亮WS2812RGB灯被打赏50分 |