论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > C语言程序设计教程
Tag:新手,函数,指针,数据类型,对象,Turbo,入门,运算符,数组,结构,二级,,tc,游戏,试题,问答,编译,视频教程

C语言时钟源程序(按机械表行走和按电子表显示时间和日期)

文章类别:C语言程序设计 | 发表日期:2008-9-24 14:44:58

**************************************************************
* C语言时钟源程序
* 南阳理工学院计算机系01612班大鹏课程设计作品
* 运行环境:TC2.0
* Email:ypsky@mail2.nyist.net
*************************************************************
#include"graphics.h"
#define PI 3.1416
#include"math.h"
#include"dos.h"
main()
{
int x0=320,y0=240,r0=150;
void init_sceen();
void sec();
init_sceen(x0,y0,r0);
sec();
closegraph();
}
void init_sceen(int x0,int y0,int r0)/********************************************/
{
int i,x,y,graphdriver,graphmode;
char s[10];
float alpha,a0=90;

graphdriver=DETECT;
initgraph(&graphdriver,&graphmode,"");
setbkcolor(3);
setcolor(2);
circle(x0,y0,r0);
circle(x0,y0,r0+30);
setfillstyle(SOLID_FILL,10);
floodfill(x0-r0-10,y0,2);
/*please input the time*/
for(i=12;i>=1;i--)
{
alpha=(a0+30*(11-i)*PI/180);
x=x0+cos(alpha)*r0-16;
y=y0-sin(alpha)*r0;
sprintf(s,"%2d",i);
setcolor(4);
settextstyle(0,0,2);
outtextxy(x,y,s);
}
/*input second*/
for(i=60;i>=1;i--)
{
alpha=(a0+6*(60-i)*PI/180);
x=x0+cos(alpha)*(r0-20);
y=y0-sin(alpha)*(r0-20);
setcolor(14);
if(i%5==0)
circle(x,y,5);
else circle(x,y,2);
floodfill(x,y,14);
}
setlinestyle(0,0,3);
}
void sec(void) /******************************************************************/
{
int x,y,i,j,k,xj,yj,xk,yk,xi,yi,x0=320,y0=240,r0=150;
union REGS r;


unsigned char *shijie="";
unsigned char *daa="";
struct time tim;
struct date dat;
float alphai,alphak,alphaj,a0=90;
xi=x0;yi=y0;xj=x0;yj=y0;xk=x0;yk=y0;
do
{
/*intput the time*/
x=38;y=12;
gettime(&tim);
sprintf(shijie,"%02d:%02d:%02d",tim.ti_hour,tim.ti_min,tim.ti_sec);
setfillstyle(SOLID_FILL,0);
bar(245,190,375,210);
setcolor(15);
outtextxy(245,190,shijie);
/*input the date*/ /*****************************************************/
getdate(&dat);
sprintf(daa,"%02d--%02d--%02d",dat.da_year,dat.da_mon,dat.da_day);
/*setfillstyle(SOLID_FILL,3);*/
bar(225,290,395,310);
setcolor(RED);
outtextxy(225,290,daa);
x=190;y=430;
setcolor(RED);
outtextxy(x-26,y,"Designed by GuoLiuTa0");
setcolor(LIGHTRED);
outtextxy(x+76,y0+20,"NBA GAME");
setlinestyle(0,0,3);
k=tim.ti_hour;
j=tim.ti_min;
i=tim.ti_sec;
alphak=(a0+30*(12-k)-j*5/60.*6)*PI/180;
alphaj=(a0-6*j)*PI/180;
/*write second hand*/
alphai=(a0+6*(60-i))*PI/180;
x=x0+cos(alphai)*(r0-32);
y=y0-sin(alphai)*(r0-32);
setcolor(BLACK);
line(x0,y0,xi,yi);
setcolor(YELLOW);
line(x0,y0,x,y);
xi=x;
yi=y;
/*write minute hand*/
x=x0+cos(alphaj)*(r0-60);
y=y0-sin(alphaj)*(r0-60);
setcolor(BLACK);
line(x0,y0,xj,yj);
setcolor(BLUE);
line(x0,y0,x,y);
xj=x;
yj=y;
/*write hour hand*/
x=x0+cos(alphak)*(r0-99);
y=y0-sin(alphak)*(r0-99);
setcolor(BLACK);
line(x0,y0,xk,yk);
setcolor(RED);
line(x0,y0,x,y);
xk=x;
yk=y;
delay(10000);
}
while(!kbhit());
}


失败往往是自己的过失造成的

视频教程列表
文章教程搜索
 
C语言程序设计推荐教程
C语言程序设计热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058