#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");
             printf("2013914216\n")
             break;
        }
             if(cou==70)
             {
                 printf("tui wim!!!\n");
                 printf("2013914216\n")
                 break;
             }
        }
    }
	 



 
总结:在编写程序中,要注意所应用的变量和函数并适当使用。在本程序中龟和兔行走的原则是不同的,而且在本程序中引用了产生随机数的函数,使程序变得简单。如果不引人随机数,那么在兔子和龟的每一次行走过程中都要输入定义范围内的数。

 
					
				
 
			
			
			
						
			 我要赚赏金
 我要赚赏金 STM32
STM32 MCU
MCU 通讯及无线技术
通讯及无线技术 物联网技术
物联网技术 电子DIY
电子DIY 板卡试用
板卡试用 基础知识
基础知识 软件与操作系统
软件与操作系统 我爱生活
我爱生活 小e食堂
小e食堂

