c语言 时钟模拟
悬赏分:0 - 解决时间:2007-12-22 13:00
8.时钟模拟
图形化界面,屏幕上显示圆形的模拟时钟表盘,显示12个刻度。时钟上有秒针、分针和时针指示,随着时间推移,秒针、分针和时针在表盘上移动。
提示:
在dos.h头文件中定义有如下结构类型
struct time {
unsigned char ti_min; /* Minutes */
unsigned char ti_hour; /* Hours */
unsigned char ti_hund; /* Hundredths of seconds */
unsigned char ti_sec; /* Seconds */
};
可直接利用该类型表示时间类型。在dos.h头文件中定义库函数gettime(struct time *),该函数返回系统时钟。此程序可通过读取系统时钟调整秒针、分针和时针位置。
提问者: yjc362878182 - 试用期 一级 最佳答案
#include<math.h>
#include<dos.h>
#include<graphics.h>
#include<conio.h>
#include<time.h>
#define PI 3.141592653589793
int h,m,s,i,l,mon,y,d;
struct time t;
struct date data;
draw()
{
gettime(&t); //取得时间信息到t
s=t.ti_sec; //秒
h=t.ti_hour; //时
m=t.ti_min; //分
getdate(&data); //取得日期信息到data
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载