首页编程时钟代码(c语言时钟代码)

时钟代码(c语言时钟代码)

编程之家2023-11-03111次浏览

大家好,关于时钟代码很多朋友都还不太明白,今天小编就来为大家分享关于c语言时钟代码的知识,希望对各位有所帮助!

时钟代码(c语言时钟代码)

c语言时钟代码

#include<graphics.h>/*引入graphic.h*/

#include<math.h>/*引入math.h*/

#include<dos.h>/*引入dos.h*/

#define pi 3.1415926/*定义pi=3.14159*/

#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;

时钟代码(c语言时钟代码)

#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);

时钟代码(c语言时钟代码)

circle(300,240,5);

for(i=0;i<60;i++)/*循环(算时间)*/

{if(i%5==0) l=15;

else l=5;

x1=200*cos(i*6*pi/180)+300;

y1=200*sin(i*6*pi/180)+240;

x2=(200-l)*cos(i*6*pi/180)+300;

y2=(200-l)*sin(i*6*pi/180)+240;

line(x1,y1,x2,y2);

}

}

main()

{

int x,y;

int gd=VGA,gm=2;

unsigned char h,m,s;/*定义*/

struct time t[1];

initgraph(&gd,&gm,"d:\\tc");

init();

setwritemode(1);

gettime(t);

h=t[0].ti_hour;

m=t[0].ti_min;

s=t[0].ti_sec;/*定义时分秒*/

setcolor(7);/*设置颜色*/

d(150,h,30);

setcolor(14);

d(170,m,6);

setcolor(4);

d(190,s,6);

while(!kbhit())/*获取键盘相应*/

{while(t[0].ti_sec==s)

gettime(t);/*C语言中得到时间的函数*/

sound(400);/*计算时间……*/

delay(70);

sound(200);

delay(30);

nosound();

setcolor(4);

d(190,s,6);

s=t[0].ti_sec;

d(190,s,6);

if(t[0].ti_min!=m)

{

setcolor(14);

d(170,m,6);

m=t[0].ti_min;

d(170,m,6);

}

if(t[0].ti_hour!=h)

{ setcolor(7);

d(150,h,30);

h=t[0].ti_hour;

d(150,h,30);

sound(1000);

delay(240);

nosound();

delay(140);

sound(2000);

delay(240);

nosound();

}

}

getch();/*设置空格后退出*/

closegraph();

}

具体的。。就是套用用几个函数算时间。。

不要对这种很长的东西害怕,其实大部分都是在画这个钟~

加油哦~

c++时钟程序代码

C语言库函数里提供了一套关于时间的函数

time_t t= 0;

char day[20]={0};

t= time(0);//获取系统时间,此时t存放的是系统时间的秒值(从1970年1月1日0时开始到当前时间)

strftime(day, sizeof(day),"%Y-%m-%d%H:%M:%S", gmtime(&t));//转换为字符串格式,这里的例子是年-月-日时:分:秒

这里给出的是Linux下的例子,需要包含头文件#include<sys/time.h>。

如果是在windows下,你可以自己找找相应的头文件即可

下面是MSDN里关于时间函数的示例,仔细看几遍,相信你以后对时间操作的问题就不会抓瞎了

#include<time.h>

#include<stdio.h>

#include<sys/types.h>

#include<sys/timeb.h>

#include<string.h>

void main()

{

char tmpbuf[128], ampm[]="AM";

time_t ltime;

struct _timeb tstruct;

struct tm*today,*gmt, xmas={ 0, 0, 12, 25, 11, 93};

/* Set time zone from TZ environment variable. If TZ is not set,

* the operating system is queried to obtain the default value

* for the variable.

*/

_tzset();

/* Display operating system-style date and time.*/

_strtime( tmpbuf);

printf("OS time:\t\t\t\t%s\n", tmpbuf);

_strdate( tmpbuf);

printf("OS date:\t\t\t\t%s\n", tmpbuf);

/* Get UNIX-style time and display as number and string.*/

time(<ime);

printf("Time in seconds since UTC 1/1/70:\t%ld\n", ltime);

printf("UNIX time and date:\t\t\t%s", ctime(<ime));

/* Display UTC.*/

gmt= gmtime(<ime);

printf("Coordinated universal time:\t\t%s", asctime( gmt));

/* Convert to time structure and adjust for PM if necessary.*/

today= localtime(<ime);

if( today->tm_hour> 12)

{

strcpy( ampm,"PM");

today->tm_hour-= 12;

}

if( today->tm_hour== 0)/* Adjust if midnight hour.*/

today->tm_hour= 12;

/* Note how pointer addition is used to skip the first 11

* characters and printf is used to trim off terminating

* characters.

*/

printf("12-hour time:\t\t\t\t%.8s%s\n",

asctime( today)+ 11, ampm);

/* Print additional time information.*/

_ftime(&tstruct);

printf("Plus milliseconds:\t\t\t%u\n", tstruct.millitm);

printf("Zone difference in seconds from UTC:\t%u\n",

tstruct.timezone);

printf("Time zone name:\t\t\t\t%s\n", _tzname[0]);

printf("Daylight savings:\t\t\t%s\n",

tstruct.dstflag?"YES":"NO");

/* Make time for noon on Christmas, 1993.*/

if( mktime(&xmas)!=(time_t)-1)

printf("Christmas\t\t\t\t%s\n", asctime(&xmas));

/* Use time structure to build a customized time string.*/

today= localtime(<ime);

/* Use strftime to build a customized time string.*/

strftime( tmpbuf, 128,

"Today is%A, day%d of%B in the year%Y.\n", today);

printf( tmpbuf);

}

程序运行结果

OS time: 21:51:03

OS date: 05/03/94

Time in seconds since UTC 1/1/70: 768027063

UNIX time and date: Tue May 03 21:51:03 1994

Coordinated universal time: Wed May 04 04:51:03 1994

12-hour time: 09:51:03 PM

Plus milliseconds: 279

Zone difference in seconds from UTC: 480

Time zone name:

Daylight savings: YES

Christmas Sat Dec 25 12:00:00 1993

Today is Tuesday, day 03 of May in the year 1994.

用c++编写一个时钟的代码

http://scmbl.anyp.cn/050808213853041.aspx

这里是148款精美时钟代码

http://www.9941.cn/moban/zhong/1.htm

flash时钟,时钟,qq空间时钟代码,透明flash时钟

以下是flash时钟代码:(博客flash时钟库)

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="200">

<param name="movie" value="flash时钟地址">

<param name="quality" value="high">

<embed src="d" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>

</object>

说明:(手动插入必看)

1、width=300,height=300为flash文件的宽度和高度,你可以自定修改

2、flash时钟地址,是flash文件地址,复制以下任一地址都行,如:/free/UploadFiles_2504/clock/clock1.swf

flash时钟下载,下载方法:(请用“右键-目标另存为”方式下载,或是使用下载工具)

下面为您提供一些时钟地址,效果见FLASH栏目里的“时钟样式”专辑,也可以直接点击下面的网址查看效果。您可以对照选择您喜欢的样式。

时钟1:/free/UploadFiles_2504/clock/clock1.swf

时钟2:/free/UploadFiles_2504/clock/clock2.swf

时钟3:/free/UploadFiles_2504/clock/clock3.swf

时钟4:/free/UploadFiles_2504/clock/clock4.swf

时钟5:/free/UploadFiles_2504/clock/clock5.swf

时钟6:/free/UploadFiles_2504/clock/clock6.swf

时钟7:/free/UploadFiles_2504/clock/clock7.swf

时钟8:/free/UploadFiles_2504/clock/clock8.swf

时钟9:/free/UploadFiles_2504/clock/clock9.swf

时钟10:/free/UploadFiles_2504/clock/clock10.swf

时钟11:/free/UploadFiles_2504/clock/clock11.swf

时钟12:/free/UploadFiles_2504/clock/clock12.swf

时钟13:/free/UploadFiles_2504/clock/clock13.swf

时钟14:/free/UploadFiles_2504/clock/clock14.swf

时钟15:/free/UploadFiles_2504/clock/clock15.swf

时钟16:/free/UploadFiles_2504/clock/clock16.swf

时钟17:/free/UploadFiles_2504/clock/clock17.swf

时钟18:/free/UploadFiles_2504/clock/clock18.swf

时钟19:/free/UploadFiles_2504/clock/clock19.swf

时钟20:/free/UploadFiles_2504/clock/clock20.swf

时钟21:/free/UploadFiles_2504/clock/clock21.swf

时钟22:/free/UploadFiles_2504/clock/clock22.swf

时钟23:/free/UploadFiles_2504/clock/clock23.swf

时钟24:/free/UploadFiles_2504/clock/clock24.swf

时钟25:/free/UploadFiles_2504/clock/clock25.swf

时钟26:/free/UploadFiles_2504/clock/clock26.swf

时钟27:/free/UploadFiles_2504/clock/clock27.swf

时钟28:/free/UploadFiles_2504/clock/clock28.swf

时钟29:/free/UploadFiles_2504/clock/clock29.swf

时钟30:/free/UploadFiles_2504/clock/clock30.swf

时钟31:/free/UploadFiles_2504/clock/clock31.swf

时钟32:/free/UploadFiles_2504/clock/clock32.swf

时钟33:/free/UploadFiles_2504/clock/clock33.swf

时钟34:/free/UploadFiles_2504/clock/clock34.swf

时钟35:/free/UploadFiles_2504/clock/clock35.swf

时钟36:/free/UploadFiles_2504/clock/clock36.swf

时钟37:/free/UploadFiles_2504/clock/clock37.swf

时钟38:/free/UploadFiles_2504/clock/clock38.swf

时钟39:/free/UploadFiles_2504/clock/clock39.swf

时钟40:/free/UploadFiles_2504/clock/clock40.swf

时钟代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于c语言时钟代码、时钟代码的信息别忘了在本站进行查找哦。

代理备案?网站代理备案是真的么申请空间,如何申请QQ空间认证