C語言寫的乙個鐘錶 很炫哦

2021-04-13 09:29:04 字數 1912 閱讀 6613

下面是源**:

#include

#include

#include

#include

#define pi 3.1415926

#define x 320

#define y 240

int main()

gettime(&curtime);

/*得到當前系統時間*/

gotoxy(40,18);      /*定位輸出位置*/

setcolor(7);

outtextxy(getmaxx()/2-30,getmaxy()/4,"uestc_terryli");

setcolor(2);

rectangle(0,0,getmaxx(),getmaxy());

rectangle(20,20,getmaxx()-20,getmaxy()-20);

line(0,0,20,20);

line(getmaxx(),0,getmaxx()-20,20);

line(0,getmaxy(),20,getmaxy()-20);

line(getmaxx(),getmaxy(),getmaxx()-20,getmaxy()-20);

printf("now time:");

printf("%.0f:",(float)curtime.ti_hour);

if((float)curtime.ti_min<10) printf("0");

printf("%.0f:",(float)curtime.ti_min);

if((float)curtime.ti_sec<10) printf("0");

printf("%.0f",(float)curtime.ti_sec);

/*獲得三個圓*/

circle(x,y,200);

circle(x,y,12);

setcolor(4);         /*the first  */

circle(x,y,3);       /*the second */

setfillstyle(1,4);   /*the third  */

floodfill(x,y,4);    /*fouth      */ /*這四步畫最中間的紅圓*/

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 */

/*draw hour point*/

m = x + 90*sin(th_hour);     /*70*/

n = y - 90*cos(th_hour);

setcolor(13);

line(x,y,m,n);

/*draw minute point*/        /*110*/

m = x + 130*sin(th_min);

n = y - 130*cos(th_min);

setcolor(11);

line(x,y,m,n);

/*draw second point*/         /*140*/

m = x + 170*sin(th_sec);

n = y - 170*cos(th_sec);

setcolor(5);

line(x,y,m,n);

sleep(1);

cleardevice();

}closegraph();

return 0;

}

乙個C 鐘錶小實驗

好,在mooc上學習c 有個鐘錶小實驗,一時興起就跟著做了。對於我來說還是有點新穎的 貼上 include include using namespace std class clock void clock set int h,int m,int s,float p 設定修改四個資料成員值的函式 ...

C語言寫乙個類

ifndef 50 2 h define 50 2 h typedef void demo demo demo create int i,int j int demo geti demo pthis int demo getj demo pthis int demo add demo pthis,i...

C語言寫乙個雜湊表

目錄 雜湊表,就是下標可以為字母的陣列。假設現有乙個陣列int a 100 想查詢其中第40個元素,則直接輸入a 40 就可以了,時間複雜度為o 1 o 1 o 1 問題在於,當下標不是數字,而是乙個字串的時候,可能需要乙個超大的空間才能將所有下標妥善地存放在特定的位置。例如,若以大小寫字母作為下標...