国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > C > 正文

電腦開(kāi)機(jī)時(shí)間的計(jì)算代碼

2020-01-26 16:11:30
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

函數(shù)功能:GetTickCount返回(retrieve)從操作系統(tǒng)啟動(dòng)到現(xiàn)在所經(jīng)過(guò)(elapsed)的毫秒數(shù),它的返回值是DWORD.

知道了這個(gè),這個(gè)程序也就不是什么難事了。。。

CODE:

復(fù)制代碼 代碼如下:

#include <stdlib.h>
 #include <time.h>
 #include <windows.h>
 #include <stdio.h>

 typedef struct node
 {
     int h;
     int m;
     int s;
 }
 *PTime;

 void sleep(long wait);

 void gettime();

 int main()
 {
     PTime times;
     int flag = 1;
     char time[128];
     do
     {
         _strtime(time); // Gets the current system time (do not include the date)
         system("cls"); // clear screen
         printf("OS time: %s/n",time);

         gettime(times); // call gettime()
         sleep(1000); // sleep 1 second

         printf("已開(kāi)機(jī)時(shí)間: %02d小時(shí)%02d分%02d秒/n", times->h, times->m, times->s);
     }while(flag); // always cycle

     return 0;
 }

 void sleep(long wait)
 {
     long goal; // define total time
     goal = wait + clock();
     while(goal > clock());
 }

 PTime gettime(PTime T)
 {
     int i = GetTickCount();
     T->h = (i / 1000) / 3600;
     T->m = (i / 1000) / 60 - T->h * 60;
     T->s = (i / 1000) - T->h * 3600 - T->m * 60;
     return T;
 }

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 噶尔县| 乐都县| 惠来县| 英山县| 利川市| 崇州市| 永康市| 石河子市| 萨嘎县| 岢岚县| 永城市| 聂拉木县| 弋阳县| 六枝特区| 佛坪县| 汝州市| 建德市| 隆尧县| 塔城市| 平安县| 奎屯市| 开原市| 佛冈县| 丁青县| 右玉县| 石台县| 色达县| 长白| 瑞安市| 睢宁县| 腾冲县| 新野县| 耒阳市| 麻城市| 新化县| 土默特右旗| 北票市| 焦作市| 武隆县| 祥云县| 墨玉县|