- WinCE Security...
 - xdebug配置说明
 - VC++ 获取文件的创建、修...
 - ASP进度条
 - 简单代理服务器C代码实现(S...
 - 程序设计竞赛试题选(02)
 - 如何在ASP程序中打印Acc...
 - UTF-8和16进制区间
 - ASP实用技巧:强制刷新和判...
 - 运行中程序删除自己的方法
 - asp提高首页性能的一个技巧
 - [J2EE]J2EE 应用服务器技术
 - VB变量命名规范
 - C语言常见错误小结
 - (摘自网络)如何在IIS中调...
 
以钟表的形式实时显示系统时间
/*
    CLOCK.C -- 以钟表的形式实时显示系统时间
*/
#include "stdlib.h"
#include "conio.h"
#include "stdio.h"
#include "graphics.h"
#include "math.h"
#include "dos.h"
#define   BB   3.14159/180
void InitGra(void);
void SysTime(int x, int y, int r);
int  Clock(int x, int y, int r);
void ClockPict(int x, int y, int r);
int main(void)
{
    int x, y, r;  /* 定义表盘的中心及半径 */
    x = 310;
    y = 240;
    r = 42;
    InitGra();
    SysTime(x, y, r);
    closegraph();
    return(0);
}
void InitGra(void)
{
   int  GraphDrive = DETECT, GraphMode;
   reGISterbgidriver(EGAVGA_driver);
   initgraph(&GraphDrive, &GraphMode, "");
}
void SysTime(int x, int y, int r)  /* 表盘中心坐标, 半径 */
{
    ClockPict(x, y, r);
    while ((Clock(x, y, r) != 1) && (! kbhit())); /* 钟表运行直到按键为止 */
}
int Clock(int x, int y, int r)      /* 表盘中心, 表盘半径 */
{
    float hr, mt, sd, dh, dm, ds, ds0;
    int i, Fst = 1;
    union REGS in, out;
    setcolor(0); setfillstyle(1, 0);
    pieslice(x, y, 0, 360, r-11);
    in.h.ah = 0x2c;
    int86(0x21, &in, &out);
    hr = out.h.ch;          /* 时 */
    mt = out.h.cl;          /* 分 */
    sd = out.h.dh;          /* 秒 */
    if (hr > 12)  hr = hr-12;
    hr = hr+mt/60;
    dh = 270+30*hr;if (dh > 360) dh = dh-360; dh = dh*BB;
    dm = 270+6*mt; if (dm > 360) dm = dm-360; dm = dm*BB;
    ds = 270+6*sd; if (ds > 360) ds = ds-360; ds = ds*BB;
    setcolor(15); setlinestyle(0, 0, 3);
    line(x, y, x+(r-20)*cos(dh), y+(r-20)*sin(dh));   /* 画时针 */
    setlinestyle(0,0,1);
    line(x, y, x+(r-15)*cos(dm), y+(r-15)*sin(dm));   /* 画分针 */
    setwritemode(XOR_PUT);
    for (i = 0; i < 300; i++)
    {
       in.h.ah = 0x2c;                    /* 循环内执行秒针的走动 */
       int86(0x21, &in, &out);
       sd = out.h.dh;
       ds = 270+6*sd;
       if (ds > 360) ds = ds-360;
       ds = ds*BB;
       if (Fst)  ds0 = ds;
       setlinestyle(0, 0, 1); setcolor(12);
       if (!Fst) line(x,y,x+(r-12)*cos(ds0),y+(r-12)*sin(ds0)); /* 擦去原秒针*/
       line(x, y, x+(r-12)*cos(ds), y+(r-12)*sin(ds));           /* 重画秒针 */
       ds0 = ds; Fst = 0;
       if (kbhit()) return (1);          /* 如果有按键, 返回 */
       else delay(100);
   }
}
void ClockPict(int x, int y, int r)    /* 画表盘 */
{
    float af;
    int i, Dlt;
    setwritemode(COPY_PUT); setlinestyle(0,0,1);
    setcolor(0); setfillstyle(1,0);
    pieslice(x, y, 0, 360, r+2);
    setcolor(14);
    circle(x, y, r);
    line(x+r+5, y-2, x+r+10, y-2);
    line(x+r+5, y+2, x+r+10, y+2);
    setlinestyle(0,0,3);
    rectangle(x+r+5, y-6, x+r+10, y+6);
    circle(x, y, r+5);
    for (i = 0; i < 360; i += 30)             /*  画表的时刻刻度   */
    {
       af = i*BB;
       if (i==0 || i==90 || i==180 || i==270) Dlt = 8; /* 3,6,9,12点刻度稍长*/
       else Dlt = 5;
       line(x+(r-Dlt)*cos(af), y+(r-Dlt)*sin(af), x+r*cos(af), y+r*sin(af));
    }
}