2个回答
2013-07-24
展开全部
/*开发环境:turbo c 2.0模拟时钟转动程序代码*/
#include"graphics.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 init() /*划时钟边框函数*/
{
int i,l,x1,x2,y1,y2;
setbkcolor(1);
circle(300,240,200);
circle(300,240,205);
circle(300,240,5);
for(i=0;i<60;i++) /*划钟点上的短线*/
{
if(i%5==0)
l=15;
else
l=5;
x1=200*sin(i*6*pi/180)+300;
y1=200*cos(i*6*pi/180)+240;
x2=(200-l)*sin(i*6*pi/180)+300;
y2=(200-l)*cos(i*6*pi/180)+240;
line(x1,y1,x2,y2);
}
}
main()
{
int x,y,i,k=1;
int gdriver=9,gmode=2;
unsigned char h,m,s;
int o,p,q;
float n;
struct time t[1];
struct date d[1];
initgraph(&gdriver,&gmode,"c:\\tc");
initgraph(&gdriver,&gmode,"c:\\tc");
for(i=0;i<=6;i++)
{
settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); /*控制输出字符的字体,方向,大小*/
cleardevice();
settextjustify(1,1); /*在指定坐标上输出字符串*/
outtextxy(300,80,"12") ;
outtextxy(300,390,"6");
outtextxy(140,230,"9");
outtextxy(460,230,"3");
outtextxy(380,100,"1");
outtextxy(220,100,"11");
outtextxy(430,160,"2");
outtextxy(430,310,"4");
outtextxy(380,370,"5");
outtextxy(220,370,"7");
outtextxy(160,160,"10");
outtextxy(160,310,"8");
}
init();
setwritemode(1); /*设置画线的输出模式*/
if(k!=0)
{
getdate(d); /*获得系统日期函数*/
o=d[0].da_year;
p=d[0].da_mon;
q=d[0].da_day;
gettime(t); /*获得系统时间函数*/
h=t[0].ti_hour;
m=t[0].ti_min;
s=t[0].ti_sec;
}
#include"graphics.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 init() /*划时钟边框函数*/
{
int i,l,x1,x2,y1,y2;
setbkcolor(1);
circle(300,240,200);
circle(300,240,205);
circle(300,240,5);
for(i=0;i<60;i++) /*划钟点上的短线*/
{
if(i%5==0)
l=15;
else
l=5;
x1=200*sin(i*6*pi/180)+300;
y1=200*cos(i*6*pi/180)+240;
x2=(200-l)*sin(i*6*pi/180)+300;
y2=(200-l)*cos(i*6*pi/180)+240;
line(x1,y1,x2,y2);
}
}
main()
{
int x,y,i,k=1;
int gdriver=9,gmode=2;
unsigned char h,m,s;
int o,p,q;
float n;
struct time t[1];
struct date d[1];
initgraph(&gdriver,&gmode,"c:\\tc");
initgraph(&gdriver,&gmode,"c:\\tc");
for(i=0;i<=6;i++)
{
settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); /*控制输出字符的字体,方向,大小*/
cleardevice();
settextjustify(1,1); /*在指定坐标上输出字符串*/
outtextxy(300,80,"12") ;
outtextxy(300,390,"6");
outtextxy(140,230,"9");
outtextxy(460,230,"3");
outtextxy(380,100,"1");
outtextxy(220,100,"11");
outtextxy(430,160,"2");
outtextxy(430,310,"4");
outtextxy(380,370,"5");
outtextxy(220,370,"7");
outtextxy(160,160,"10");
outtextxy(160,310,"8");
}
init();
setwritemode(1); /*设置画线的输出模式*/
if(k!=0)
{
getdate(d); /*获得系统日期函数*/
o=d[0].da_year;
p=d[0].da_mon;
q=d[0].da_day;
gettime(t); /*获得系统时间函数*/
h=t[0].ti_hour;
m=t[0].ti_min;
s=t[0].ti_sec;
}
推荐于2018-03-23
展开全部
#include <stdio.h>
#include <graphics.h>
#include <dos.h>
#include <math.h>
#include <conio.h>
initialize()
{
int driver, gmode;
driver=VGA;
gmode=VGAHI;
initgraph(&driver, &gmode, "F:\\turboc");
}
void main()
{
struct time tt;
int p[8];
int i,t,deg;
char s[100],dt[3][3];
double x,x1,y,y1,x2,y2,x3,y3;
gettime(&tt);
deg=tt.ti_sec;
deg=(90-deg)*6;
x1=0;
y1=100;
t=0;
while(kbhit())
{getch();}
initialize();
setbkcolor(LIGHTBLUE);
setfillstyle(SOLID_FILL,BLUE);
setcolor(LIGHTCYAN);
for(i=1;i<=5;i++)
{
circle(200,200,120+i);
}
moveto(200,90);
outtext("12");
moveto(310,200);
outtext("3");
moveto(200,310);
outtext("6");
moveto(90,200);
outtext("9");
i=1;
moveto(400,50);
outtext("Now,The Time Is:");
moveto(400,200);
outtext("Course Seconds Is:");
while(1)
{setcolor(BLUE);<br/>x=sin(3.14*deg/180)*100;<br/>y=cos(3.14*deg/180)*100;<br/>x1=200+(int)x;<br/>y1=200+(int)y;<br/>x=sin(3.14*(deg-30)/180)*20;<br/>y=cos(3.14*(deg-30)/180)*20;<br/>x2=200+(int)x;<br/>y2=200+(int)y;<br/>x=sin(3.14*(deg+30)/180)*20;<br/>y=cos(3.14*(deg+30)/180)*20;<br/>x3=200+(int)x;<br/>y3=200+(int)y;<br/>p[0]=200;p[1]=200;<br/>p[2]=x2,p[3]=y2;<br/>p[4]=x1,p[5]=y1;<br/>p[6]=x3;p[7]=y3;<br/>fillpoly(4,p);<br/>drawpoly(4,p);<br/>sleep(1);<br/>setfillstyle(SOLID_FILL,LIGHTBLUE);<br/>setcolor(LIGHTBLUE);<br/>fillpoly(4,p);<br/>drawpoly(4,p);<br/>deg=deg-6;<br/>setfillstyle(SOLID_FILL,BLUE);<br/>bar(390,230,430,270);<br/>moveto(400,250);<br/>itoa(t,s,10);<br/>outtext(s);<br/>bar(390,80,480,120);<br/>moveto(400,100);<br/>gettime(&tt);<br/>itoa(tt.ti_hour,dt[0],10);<br/>itoa(tt.ti_min,dt[1],10);<br/>itoa(tt.ti_sec,dt[2],10);<br/>outtext(dt[0]);<br/>outtext(":");<br/>outtext(dt[1]);<br/>outtext(":");<br/>outtext(dt[2]);<br/>t++;<br/>if(deg==0)<br/>deg=360;<br/>if(kbhit())<br/>{<br/>getch();<br/>break;<br/>}
}
}
#include <graphics.h>
#include <dos.h>
#include <math.h>
#include <conio.h>
initialize()
{
int driver, gmode;
driver=VGA;
gmode=VGAHI;
initgraph(&driver, &gmode, "F:\\turboc");
}
void main()
{
struct time tt;
int p[8];
int i,t,deg;
char s[100],dt[3][3];
double x,x1,y,y1,x2,y2,x3,y3;
gettime(&tt);
deg=tt.ti_sec;
deg=(90-deg)*6;
x1=0;
y1=100;
t=0;
while(kbhit())
{getch();}
initialize();
setbkcolor(LIGHTBLUE);
setfillstyle(SOLID_FILL,BLUE);
setcolor(LIGHTCYAN);
for(i=1;i<=5;i++)
{
circle(200,200,120+i);
}
moveto(200,90);
outtext("12");
moveto(310,200);
outtext("3");
moveto(200,310);
outtext("6");
moveto(90,200);
outtext("9");
i=1;
moveto(400,50);
outtext("Now,The Time Is:");
moveto(400,200);
outtext("Course Seconds Is:");
while(1)
{setcolor(BLUE);<br/>x=sin(3.14*deg/180)*100;<br/>y=cos(3.14*deg/180)*100;<br/>x1=200+(int)x;<br/>y1=200+(int)y;<br/>x=sin(3.14*(deg-30)/180)*20;<br/>y=cos(3.14*(deg-30)/180)*20;<br/>x2=200+(int)x;<br/>y2=200+(int)y;<br/>x=sin(3.14*(deg+30)/180)*20;<br/>y=cos(3.14*(deg+30)/180)*20;<br/>x3=200+(int)x;<br/>y3=200+(int)y;<br/>p[0]=200;p[1]=200;<br/>p[2]=x2,p[3]=y2;<br/>p[4]=x1,p[5]=y1;<br/>p[6]=x3;p[7]=y3;<br/>fillpoly(4,p);<br/>drawpoly(4,p);<br/>sleep(1);<br/>setfillstyle(SOLID_FILL,LIGHTBLUE);<br/>setcolor(LIGHTBLUE);<br/>fillpoly(4,p);<br/>drawpoly(4,p);<br/>deg=deg-6;<br/>setfillstyle(SOLID_FILL,BLUE);<br/>bar(390,230,430,270);<br/>moveto(400,250);<br/>itoa(t,s,10);<br/>outtext(s);<br/>bar(390,80,480,120);<br/>moveto(400,100);<br/>gettime(&tt);<br/>itoa(tt.ti_hour,dt[0],10);<br/>itoa(tt.ti_min,dt[1],10);<br/>itoa(tt.ti_sec,dt[2],10);<br/>outtext(dt[0]);<br/>outtext(":");<br/>outtext(dt[1]);<br/>outtext(":");<br/>outtext(dt[2]);<br/>t++;<br/>if(deg==0)<br/>deg=360;<br/>if(kbhit())<br/>{<br/>getch();<br/>break;<br/>}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询