日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

easy_x是实现钟表

發(fā)布時間:2024/3/12 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 easy_x是实现钟表 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#include <graphics.h> // 引用圖形庫頭文件 #include <conio.h> #include<math.h>//畫面尺寸 #define High 480 #define Width 640 #define PI 3.14159 int main() {initgraph(Width, High);//初始化畫布int center_x, center_y;//中心坐標center_x = Width / 2;center_y = High / 2;int secondLength;secondLength = Width / 5;int minute_Length;minute_Length = Width / 7;int hour_Length;hour_Length = Width / 9;int secondEnd_x, secondEnd_y;int minute_x, minute_y;int hour_x, hour_y;float secondAngle = 0;//秒針對應轉動的角度float minuteAngle = 0;float hourAngle = 0;setcolor(WHITE);circle(center_x, center_y, Width / 4);SYSTEMTIME ti;BeginBatchDraw();while (1){GetLocalTime(&ti);//得到當前的時間secondAngle = ti.wSecond * 2 * (PI / 60);secondEnd_x = center_x + secondLength*sin(secondAngle);secondEnd_y = center_y - secondLength*cos(secondAngle);minuteAngle = ti.wMinute * 2 * (PI / 60);minute_x = center_x + minute_Length*sin(minuteAngle);minute_y = center_y - minute_Length*cos(minuteAngle);hourAngle = ti.wHour * 2 * (PI / 12);hour_x = center_x + hour_Length*sin(hourAngle);hour_y = center_y - hour_Length*cos(hourAngle);//畫秒針setlinestyle(PS_SOLID, 1);//設置秒針的樣式和寬度setcolor(YELLOW);//秒針的顏色line(center_x, center_y, secondEnd_x, secondEnd_y);//畫分針setlinestyle(PS_SOLID, 2);//設置分針的樣式和寬度setcolor(BLUE);//分針的顏色line(center_x, center_y, minute_x, minute_y);//畫時針setlinestyle(PS_SOLID, 3);//設置時針的樣式和寬度setcolor(RED);//時針的顏色line(center_x, center_y, hour_x, hour_y);FlushBatchDraw();Sleep(1000);//隱藏前一秒的指針setcolor(BLACK);line(center_x, center_y, secondEnd_x, secondEnd_y);line(center_x, center_y, minute_x, minute_y);line(center_x, center_y, hour_x, hour_y);}EndBatchDraw();_getch();closegraph();return 0; }

總結

以上是生活随笔為你收集整理的easy_x是实现钟表的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。