剪力墙轴压比小于0.3:【C语言】大家帮我看看呀,时钟没问题,下方的摆怎么有一部分摆过之后擦不掉(把摆单独运行没问题)

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 00:29:34
大家帮我看看呀,时钟没问题,下方的摆怎么有一部分摆过之后擦不掉(把摆单独运行没问题),我不知道怎么回事啊,谢谢指教。

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>

#define pi 3.1415926
#define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300;
#define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240;
#define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y)

void main()
{
int gd=DETECT,gm;
int x=300,y=240,r=60,i=0,j;
unsigned char h,m,s;
struct time t;
char n[12][3]={"3","2","1","12","11","10","9","8","7","6","5","4"};
initgraph(&gd,&gm,"");
circle(x,y,70);
circle(x,y,72); /*画圆*/
arc(300,250,0,180,100); /*时钟下边的钟摆框架*/
line(200,250,200,450);
line(200,450,400,450);
line(400,450,400,250);
line(200,315,400,315);
setcolor(4);
settextstyle(2,0,3);
for(i=0;i<12;i++)
{outtextxy(x+(r+3)*cos(M_PI/6*i)-2,y-(r+3)*sin(M_PI/6*i)-4,n[i]);} /*钟表数字*/
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d\n",t.ti_hour, t.ti_min,
t.ti_sec, t.ti_hund);

setwritemode(1);
h=t.ti_hour;
m=t.ti_min;
s=t.ti_sec;
setcolor(7);
d(30,h,30);
setcolor(14);
d(40,m,6);
setcolor(4);
d(50,s,6);
while(!kbhit())
{
while(t.ti_sec==s)
gettime(&t);
sound(400);
delay(70);
sound(200);
delay(30);
nosound();
setcolor(4);
d(50,s,6);
s=t.ti_sec;
d(50,s,6);

for(j=600;j<1200;j++) /*钟下方的摆*/
{
setcolor(0);
line(300,315,300+100*cos((j-1)*M_PI/1800),315+100*sin((j-1)*M_PI/1800));
circle(300+100*cos((j-1)*M_PI/1800),315+100*sin((j-1)*M_PI/1800),5);
setcolor(1);
line(300,315,300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800));
circle(300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800),5);
}
for(j=1200;j>600;j--)
{
setcolor(0);
line(300,315,300+100*cos((j+1)*M_PI/1800),315+100*sin((j+1)*M_PI/1800));
circle(300+100*cos((j+1)*M_PI/1800),315+100*sin((j+1)*M_PI/1800),5);
setcolor(1);
line(300,315,300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800));
circle(300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800),5);
}

if(t.ti_min!=m)
{
setcolor(14);
d(40,m,6);
m=t.ti_min;
d(40,m,6);
}
if (t.ti_hour!=h)
{ setcolor(7);
d(30,h,30);
h=t.ti_hour;
d(30,h,30);
sound(1000);
delay(240);
nosound();
delay(140);
sound(2000);
delay(240);
nosound();
}
}
getch();
closegraph();
}
回 秋风_落叶:谢谢,当时没想到^_^,这个解决了一部分但关键的还是没有,还是有一半擦不掉
谢谢 wfengling,又找到了一个学习的网站^_^

以下初步改动,因为没有TC,而WIN C下的没有VGA的编程函数,所以无法给你调试.

for(j=600;j<1200;j++) /*钟下方的摆*/
{
setcolor(0);
line(300,315,300+100*cos((j-1)*M_PI/1800),315+100*sin((j-1)*M_PI/1800));
circle(300+100*cos((j-1)*M_PI/1800),315+100*sin((j-1)*M_PI/1800),5);
setcolor(1);
line(300,315,300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800));
circle(300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800),5);
}
for(j=1200;j>600;j--)//改为for(j=1199;j>=600;j--)
{
setcolor(0);
line(300,315,300+100*cos((j+1)*M_PI/1800),315+100*sin((j+1)*M_PI/1800));
circle(300+100*cos((j+1)*M_PI/1800),315+100*sin((j+1)*M_PI/1800),5);
setcolor(1);
line(300,315,300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800));
circle(300+100*cos(j*M_PI/1800),315+100*sin(j*M_PI/1800),5);
}

不是很清楚