大家好!谁能帮我找一个C语言时钟程序设计?本人急用,谢谢了!

如题所述

第1个回答  2006-09-08
#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语言编写的电子时钟的程序,内容要有闹钟,可以调整时间
define unit unsigned int define uchar unsigned char \/\/#define HZ 12 sbit key0=P0^0; \/\/ 分钟调整 sbit key1=P0^1; \/\/ 小时调整 sbit P2_0=P2^7; \/\/秒 指示灯 sbit MN_RXD=P3^6;sbit MN_TXD=P3^7;uchar data CLOCK[4]={0,0,0,12};\/\/存放时钟时间(百分秒,秒...

c语言怎么样编写一个时钟程序
define ID_TIMER 1\/\/计时器ID define TWOPI (2*3.14159)LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdLine,int iCmdShow){ static TCHAR szAppName[]=TEXT("Clock");HWND hwnd;MSG msg;WNDCLASS wndclass;wndclass.c...

用c语言编一个时钟程序实现时分秒计时功能
include int main(){ time_t t1,t2;struct tm *ptm;char timestr[128]={'\\0'};time(&t1);while(1){ time(&t2);if(difftime(t2,t1)>=1){ system("cls");ptm=localtime(&t2);strftime(timestr,128,"%H:%M:%S",ptm);printf("%s\\n",timestr);t1=t2;} } system("PAUSE");r...

谁能帮我编一个C语言时钟啊
setcur(x,y);\/* 1:┌ 2:┐ 3:└ 4:┘ 5:┼ 6:─ 7:│ 8:┬ 9:├ 10:┤11:┴ *\/

求一个51单片机定时闹钟程序。要C语言。能够调时间
我来发一个C语言51单片机时钟程序,希望能帮到你 \/* 程序功能:带定时闹铃时钟 *\/ \/*---*\/ include <AT89X51.H> \/*包含器件配置文件*\/ define uchar unsigned char define uint unsigned int char DATA_7SEG[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,};\/*...

怎么用C语言编程数字时钟
&graphmode,"C:\\\\TC2"); \/\/初始化VGA屏幕模式setbkcolor(BLACK); \/\/使用黑色的背景色while(!kbhit(0)) \/\/若有键盘输入,则跳出,即是结束程序{ setcolor(GREEN); \/\/把画笔设为绿色circle(mid_x,mid_y,180); \/\/钟的外圆circle(mid_x,mid_y,150); \/\/钟的内圆circle(mid_x,mid_y,...

用c语言模拟一个数字时钟,要求延时一秒运行
1、用sleep延时刷新并获取系统时间来显示。2、例程:include<graphics.h> #include<math.h> #include<dos.h> #define PI 3.1415926 \/\/屏幕中心的坐标(640X480模式下)#define mid_x 320 #define mid_y 240 int main() { int graphdriver=DETECT,graphmode; int end_x,end_y; struct time ...

用C语言编数码管时钟程序
\/\/G, F A E B H C D sbit l1=P2^7;sbit l2=P2^6;sbit l3=P2^5;sbit l4=P2^4;sbit l5=P2^3;sbit l6=P2^2;sbit l7=P2^1;sbit l8=P2^0;sbit j1=P1^1;sbit j2=P1^2;unsigned char code ledcode[]={0x84,0xf5,0x46,0x54,0x35,0x1c,0x0c,0xd5...

C语言程序设计题:模拟时钟转动的程序,怎么做?
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(...

用C语言编一个数字电子时钟的程序
1.这是用windows api写的程序。所以要求是纯c的话就没有办法了2.其中定时用了两种方法。一种是用取消息。另一种是延时队列。这里只使用了取消息的方法。延时队列由于我机器上是vc6.0,CreateTimerQueue在本人机器上无法使用,需要新的sdk,所以没有加以验证,但取消息的方式是可行的。3.稍稍验证了下,基本满足要求。

相似回答