函数没有的情况下我该怎么办?

勇敢的搬砖人 2008-10-26 06:33:24
这是一个TC下运行的程序,不过TC已经过时, 怎么修改一下让其在VC环境下运行?


#include<graphics.h>
#include<math.h>
#include<dos.h>
#define PI 3.1415926
#define mid_x 320 /*定义钟表中心坐标*/
#define mid_y 240

int main()
{
int graphdriver=0,graphmode;
int end_x,end_y;
struct time curtime;
float th_hour,th_min,th_sec;
initgraph(&graphdriver,&graphmode,"e:\\TC");
setbkcolor(0);
while(! kbhit())/*有键盘输入时退出*/
{
/*画表盘*/
setcolor(14);
circle(mid_x,mid_y,150);
circle(mid_x,mid_y,2);
gettime(&curtime); /*得到当前系统时间*/
/*以下三行计算表针转动角度,以竖直向上为起点,顺时针为正*/
th_sec=(float)curtime.ti_sec*0.1047197551; /*2π/60=0.1047197551*/
th_min=(float)curtime.ti_min*0.1047197551+th_sec/60.0;
th_hour=(float)curtime.ti_hour*0.523598775+th_min/12.0; /*2π/12=0.5235987755*/
/*画时针*/
end_x=mid_x+70*sin(th_hour);
end_y=mid_y-70*cos(th_hour);
setcolor(5);
line(mid_x,mid_y,end_x,end_y);
/*画分针*/
end_x=mid_x+110*sin(th_min);
end_y=mid_y-110*cos(th_min);
setcolor(5);
line(mid_x,mid_y,end_x,end_y);
/*画秒针*/
end_x=mid_x+140*sin(th_sec);
end_y=mid_y-140*cos(th_sec);
setcolor(5);
line(mid_x,mid_y,end_x,end_y);
sleep(1); /*延时一秒后刷新*/
cleardevice();
}
closegraph();
return 0;
}
...全文
243 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
帅得不敢出门 2008-10-27
  • 打赏
  • 举报
回复
扔掉TC 哈哈.
九桔猫 2008-10-27
  • 打赏
  • 举报
回复
楼主重写把,这可不是简单改下就能完成的任务,TC和VC整个是两套不同的画图方案
zzzlll1983 2008-10-27
  • 打赏
  • 举报
回复
重写吧!~
Big鹏 2008-10-27
  • 打赏
  • 举报
回复

VC是不支持#include <graphics.h>的,我曾也试过把graphics移到VC下,也不行。
除了用GDI相关的绘图函数重写,还可考虑用BOOST库,但不是标准的,需加载!!
  • 打赏
  • 举报
回复
这个.....
还是用GDI相关的绘图函数重写吧.
liubuweiright 2008-10-26
  • 打赏
  • 举报
回复
VC6.0没有<graphic.h>头文件,,

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧