| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1386 人关注过本帖
标题:wintc下怎么不显示
只看楼主 加入收藏
jxk821015
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-8-22
收藏
 问题点数:0 回复次数:3 
wintc下怎么不显示

#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 gdrive = DETECT, gmode;

initgraph(&gdrive, &gmode, "");
}

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

getch();

}
这本来是个时钟程序,怎么在wintc下运行不来呢,我要设置什么东西吗?

搜索更多相关主题的帖子: wintc 
2006-09-04 20:43
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 

/*这份代码经源码格式软件格式化过
yang_hx@neusoft.com */
#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));
}
}
/*试试这个*/


倚天照海花无数,流水高山心自知。
2006-09-04 20:59
jxk821015
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-8-22
收藏
得分:0 
ok

2006-09-04 21:18
高阁逆风
Rank: 5Rank: 5
等 级:职业侠客
威 望:8
帖 子:508
专家分:321
注 册:2006-4-29
收藏
得分:0 
强悍!!!

      上天安排我做了个多情的人,却又安排我遭遇了无数绝情的人,所以我最终把自己磨练成了一个滥情的人。别人是人见人爱,我是见人爱人.......
2006-09-10 23:46
快速回复:wintc下怎么不显示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014235 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved