跪求C语言编写的时钟(能修改时钟时间,且时钟是指针式的 只编写修改时间的部分也行)
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/01 13:29:19
跪求C语言编写的时钟(能修改时钟时间,且时钟是指针式的 只编写修改时间的部分也行)
![跪求C语言编写的时钟(能修改时钟时间,且时钟是指针式的 只编写修改时间的部分也行)](/uploads/image/z/7636815-63-5.jpg?t=%E8%B7%AA%E6%B1%82C%E8%AF%AD%E8%A8%80%E7%BC%96%E5%86%99%E7%9A%84%E6%97%B6%E9%92%9F%EF%BC%88%E8%83%BD%E4%BF%AE%E6%94%B9%E6%97%B6%E9%92%9F%E6%97%B6%E9%97%B4%2C%E4%B8%94%E6%97%B6%E9%92%9F%E6%98%AF%E6%8C%87%E9%92%88%E5%BC%8F%E7%9A%84+%E5%8F%AA%E7%BC%96%E5%86%99%E4%BF%AE%E6%94%B9%E6%97%B6%E9%97%B4%E7%9A%84%E9%83%A8%E5%88%86%E4%B9%9F%E8%A1%8C%EF%BC%89)
////////////////////////////////////////////
// 程序名称:钟表模拟程序(表针形式)
// 编译环境:Visual C++ 6.0,EasyX 2011惊蛰版
// 程序编写:BestAns <BestAns@qq.com>
// 最后更新:2010-10-30
//
#include
<graphics.h>
#include
<conio.h>
#include
<math.h>
#define
PI
3.1415926536
void
DrawHand
(
int
hour
,
int
minute
,
int
second
)
{
double
a_hour
,
a_min
,
a_sec
;
// 时、分、秒针的弧度值
int
x_hour
,
y_hour
,
x_min
,
y_min
,
x_sec
,
y_sec
;
// 时、分、秒针的末端位置
// 计算时、分、秒针的弧度值
a_sec
=
second
*
2
*
PI
/
60
;
a_min
=
minute
*
2
*
PI
/
60
+
a_sec
/
60
;
a_hour
=
hour
*
2
*
PI
/
12
+
a_min
/
12
;
// 计算时、分、秒针的末端位置
x_sec
=
int
(
120
*
sin
(
a_sec
));
y_sec
=
int
(
120
*
cos
(
a_sec
));
x_min
=
int
(
100
*
sin
(
a_min
));
y_min
=
int
(
100
*
cos
(
a_min
));
x_hour
=
int
(
70
*
sin
(
a_hour
));
y_hour
=
int
(
70
*
cos
(
a_hour
));
// 画时针
setlinestyle
(
PS_SOLID
,
NULL
,
10
);
setcolor
(
WHITE
);
line
(
320
+
x_hour
,
240
-
y_hour
,
320
-
x_hour
/
7
,
240
+
y_hour
/
7
);
// 画分针
setlinestyle
(
PS_SOLID
,
NULL
,
6
);
setcolor
(
LIGHTGRAY
);
line
(
320
+
x_min
,
240
-
y_min
,
320
-
x_min
/
5
,
240
+
y_min
/
5
);
// 画秒针
setlinestyle
(
PS_SOLID
,
NULL
,
2
);
setcolor
(
RED
);
line
(
320
+
x_sec
,
240
-
y_sec
,
320
-
x_sec
/
3
,
240
+
y_sec
/
3
);
}
void
DrawDial
()
{
// 绘制一个简单的表盘
circle
(
320
,
240
,
2
);
circle
(
320
,
240
,
60
);
circle
(
320
,
240
,
160
);
outtextxy
(
296
,
310
,
"BestAns"
);
// 绘制刻度
int
x
,
y
;
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
x
=
320
+
int
(
145
*
sin
(
PI
*
2
*
i
/
60
));
y
=
240
+
int
(
145
*
cos
(
PI
*
2
*
i
/
60
));
if
(
i
%
15
==
0
)
bar
(
x
-
5
,
y
-
5
,
x
+
5
,
y
+
5
);
else
if
(
i
%
5
==
0
)
circle
(
x
,
y
,
3
);
else
putpixel
(
x
,
y
,
WHITE
);
}
}
void
main
()
{
initgraph
(
640
,
480
);
// 初始化 640 x 480 的绘图窗口
DrawDial
();
// 绘制表盘
setwritemode
(
R2_XORPEN
);
// 设置 XOR 绘图模式
// 绘制表针
SYSTEMTIME
ti
;
// 定义变量保存当前时间
while
(!
kbhit
())
// 按任意键退出钟表程序
{
GetLocalTime
(&
ti
);
// 获取当前时间
DrawHand
(
ti
.
wHour
,
ti
.
wMinute
,
ti
.
wSecond
);
// 画表针
Sleep
(
1000
);
// 延时 1 秒
DrawHand
(
ti
.
wHour
,
ti
.
wMinute
,
ti
.
wSecond
);
// 擦表针(擦表针和画表针的过程是一样的)
}
closegraph
();
// 关闭绘图窗口
} 其了就是用了easyx
再问: 800行的代码,格式也不对,你也太高估我的眼力了,大神能不能把格式整对?
再答: 格式本来是好的 贴过来就乱了 你直接看这个贴吧的帖子~~~很详细的 http://tieba.baidu.com/p/2276713341
// 程序名称:钟表模拟程序(表针形式)
// 编译环境:Visual C++ 6.0,EasyX 2011惊蛰版
// 程序编写:BestAns <BestAns@qq.com>
// 最后更新:2010-10-30
//
#include
<graphics.h>
#include
<conio.h>
#include
<math.h>
#define
PI
3.1415926536
void
DrawHand
(
int
hour
,
int
minute
,
int
second
)
{
double
a_hour
,
a_min
,
a_sec
;
// 时、分、秒针的弧度值
int
x_hour
,
y_hour
,
x_min
,
y_min
,
x_sec
,
y_sec
;
// 时、分、秒针的末端位置
// 计算时、分、秒针的弧度值
a_sec
=
second
*
2
*
PI
/
60
;
a_min
=
minute
*
2
*
PI
/
60
+
a_sec
/
60
;
a_hour
=
hour
*
2
*
PI
/
12
+
a_min
/
12
;
// 计算时、分、秒针的末端位置
x_sec
=
int
(
120
*
sin
(
a_sec
));
y_sec
=
int
(
120
*
cos
(
a_sec
));
x_min
=
int
(
100
*
sin
(
a_min
));
y_min
=
int
(
100
*
cos
(
a_min
));
x_hour
=
int
(
70
*
sin
(
a_hour
));
y_hour
=
int
(
70
*
cos
(
a_hour
));
// 画时针
setlinestyle
(
PS_SOLID
,
NULL
,
10
);
setcolor
(
WHITE
);
line
(
320
+
x_hour
,
240
-
y_hour
,
320
-
x_hour
/
7
,
240
+
y_hour
/
7
);
// 画分针
setlinestyle
(
PS_SOLID
,
NULL
,
6
);
setcolor
(
LIGHTGRAY
);
line
(
320
+
x_min
,
240
-
y_min
,
320
-
x_min
/
5
,
240
+
y_min
/
5
);
// 画秒针
setlinestyle
(
PS_SOLID
,
NULL
,
2
);
setcolor
(
RED
);
line
(
320
+
x_sec
,
240
-
y_sec
,
320
-
x_sec
/
3
,
240
+
y_sec
/
3
);
}
void
DrawDial
()
{
// 绘制一个简单的表盘
circle
(
320
,
240
,
2
);
circle
(
320
,
240
,
60
);
circle
(
320
,
240
,
160
);
outtextxy
(
296
,
310
,
"BestAns"
);
// 绘制刻度
int
x
,
y
;
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
x
=
320
+
int
(
145
*
sin
(
PI
*
2
*
i
/
60
));
y
=
240
+
int
(
145
*
cos
(
PI
*
2
*
i
/
60
));
if
(
i
%
15
==
0
)
bar
(
x
-
5
,
y
-
5
,
x
+
5
,
y
+
5
);
else
if
(
i
%
5
==
0
)
circle
(
x
,
y
,
3
);
else
putpixel
(
x
,
y
,
WHITE
);
}
}
void
main
()
{
initgraph
(
640
,
480
);
// 初始化 640 x 480 的绘图窗口
DrawDial
();
// 绘制表盘
setwritemode
(
R2_XORPEN
);
// 设置 XOR 绘图模式
// 绘制表针
SYSTEMTIME
ti
;
// 定义变量保存当前时间
while
(!
kbhit
())
// 按任意键退出钟表程序
{
GetLocalTime
(&
ti
);
// 获取当前时间
DrawHand
(
ti
.
wHour
,
ti
.
wMinute
,
ti
.
wSecond
);
// 画表针
Sleep
(
1000
);
// 延时 1 秒
DrawHand
(
ti
.
wHour
,
ti
.
wMinute
,
ti
.
wSecond
);
// 擦表针(擦表针和画表针的过程是一样的)
}
closegraph
();
// 关闭绘图窗口
} 其了就是用了easyx
![](http://img.wesiedu.com/upload/c/9c/c9c5cd44fd118e6c98316b61ad7fcaf3.jpg)
再问: 800行的代码,格式也不对,你也太高估我的眼力了,大神能不能把格式整对?
再答: 格式本来是好的 贴过来就乱了 你直接看这个贴吧的帖子~~~很详细的 http://tieba.baidu.com/p/2276713341
跪求C语言编写的时钟(能修改时钟时间,且时钟是指针式的 只编写修改时间的部分也行)
怎么把数字的时钟改成指针时钟怎么把数字的时钟改成指针时钟
格兰仕微波炉怎么调时钟的时间
指针式时钟在八点和九点之间,分针与时针夹角为54度,求此时时钟的准确时间?求出此时分针转了多少度?((一元一次方程解))
世界上第一台时钟是怎样校对时间的?
现在时钟指示的时间是10点整,如果分针旋转1996圈,那么时钟指示的时间是几点整?
时钟现在表示的时间是14时正,那么分针旋转1991周后,时钟表示的时间是( )
时钟指针重合问题的公式
时钟上的时间是3点40分,求此时时针与分针的夹角
当时钟所指时间是10:20,时钟的时针与分针所成的较小夹角是( )度
时钟的英语单词是c?ck
用C语言编写程序使89C52单片机实现数字时钟功能,显示时分秒的数码管,p1~p7接a~