| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1407 人关注过本帖
标题:帮忙改正下
只看楼主 加入收藏
plh123
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2017-6-26
结帖率:100%
收藏
 问题点数:0 回复次数:3 
帮忙改正下
#include <stdio.h>
#include <graphics.h>   
#include <conio.h>
#include <string.h>

#define time_EW 15                                    //东西方向通行时间
#define time_SN 18                                  //南北方向通行时间
#define Total 20                                    //程序运行周期


void main()
{


initgraph(600, 400);     //界面大小  (横向X轴,纵向Y轴)


int i,j;                       
for(i=50;i<=550;i=i+100)     //第一行画竖线
line(i, 50,i,150);     //(起始点横坐标,起始点纵坐标,终止点横坐标,终止点纵坐标)

for(i=50;i<=550;i=i+100)     //第二行画竖线
line(i,250,i,350);   


for(j=50;j<=400;j=j+100)     //画横线
line(50,j,550,j);   

for(i=100;i<=300;i+=100)  //使用循环画圆,精简程序
{
circle(i,100,40);
circle(i,300,40);
}
              



settextstyle(45, 0, _T("宋体"));
outtextxy(460,75,("东西"));
outtextxy(460,275,("南北"));


int m;
for(m=0;m<Total;m++){
char s[5]={0},s_1[5]={0};                                //字符数组初始化,防止越界
int Q,T;                                          //Q控制前半个周期。T控制后半个周期
for(Q=time_SN;Q>=0;Q--)
{
if(Q<10)                                      //覆盖思想
{
char s1[1];
char s2[1];
_stprintf(s1, _T("%d"),0);
strcpy(s,s1);
_stprintf(s2, _T("%d"),Q);
strcat(s,s2);
      
}




if(Q>=3)
{   
setfillcolor(RED);                        //颜色填充(覆盖)
fillcircle(100,100,40);
setfillcolor(GREEN);
fillcircle(200,300,40);
Sleep(1000);
}

if(Q<3)
{
setfillcolor(YELLOW);
fillcircle(300,300,40);
setfillcolor(BLACK);
fillcircle(200,300,40);
Sleep(500);
fillcircle(300,300,40);
Sleep(500);
fillcircle(300,300,40);
}

if(Q>=10)
{
sprintf(s, "%d", Q);
}


if((Q-3)<10&&(Q-3)>0)                                    
{
char s1[1];
char s2[1];
_stprintf(s1, _T("%d"),0);
strcpy(s_1,s1);
_stprintf(s2, _T("%d"),Q-3);
strcat(s_1,s2);
      
}
if(Q-3<=0)
{
char s1[1];
char s2[1];
_stprintf(s1, _T("%d"),0);
strcpy(s_1,s1);
_stprintf(s2, _T("%d"),Q);
strcat(s_1,s2);
      
}
if(Q-3>=10)
{
sprintf(s_1, "%d", Q-3);
}



outtextxy(380, 75,s);
outtextxy(380,275,s_1);

}

for(T=time_EW;T>=0;T--)                         //与前半个周期类似
{
if(T<10)
{
char s1[1];
char s2[1];
_stprintf(s1, _T("%d"),0);
strcpy(s,s1);
_stprintf(s2, _T("%d"),T);
strcat(s,s2);
      
}


if(T>=3)
{   
setfillcolor(GREEN);            
        fillcircle(200,100,40);
setfillcolor(BLACK);
fillcircle(100,100,40);

setfillcolor(RED);
fillcircle(100,300,40);
setfillcolor(BLACK);
fillcircle(300,300,40);
Sleep(1000);           
}
if(T<3)   
{
setfillcolor(YELLOW);
fillcircle(300,100,40);
setfillcolor(BLACK);
fillcircle(200,100,40);
Sleep(500);
fillcircle(300,100,40);
Sleep(500);
fillcircle(300,100,40);
}
if(T>=10)
{
sprintf(s, "%d", T);
}
if((T-3)<10&&(T-3)>0)                                    
{
char s1[1];
char s2[1];
_stprintf(s1, _T("%d"),0);
strcpy(s_1,s1);
_stprintf(s2, _T("%d"),T-3);
strcat(s_1,s2);
      
}
if(T-3<=0)
{
char s1[1];
char s2[1];
_stprintf(s1, _T("%d"),0);
strcpy(s_1,s1);
_stprintf(s2, _T("%d"),T);
strcat(s_1,s2);
 }
if(T-3>=10)
{
sprintf(s_1, "%d", T-3);
}
outtextxy(380, 75,s_1);
outtextxy(380,275,s);
}
setfillcolor(BLACK);
fillcircle(300,100,40);
fillcircle(100,300,40);

}
getch();     // 按任意键继续
closegraph();     // 关闭图形界面
}
搜索更多相关主题的帖子: for char strcpy strcat Sleep 
2017-06-29 18:28
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
你确认这个#include <graphics.h>     是可以使用的吗

DO IT YOURSELF !
2017-06-30 09:05
plh123
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2017-6-26
收藏
得分:0 
就是这个不能用
2017-06-30 09:38
plh123
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2017-6-26
收藏
得分:0 
我学的不太好,不知道咋改
2017-06-30 09:39
快速回复:帮忙改正下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014095 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved