国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表

圖片精選

主站蜘蛛池模板: 海原县| 华容县| 延长县| 长丰县| 博客| 游戏| 塔城市| 丹寨县| 海阳市| 瑞昌市| 子长县| 菏泽市| 禹城市| 怀仁县| 班玛县| 繁昌县| 江津市| 阿合奇县| 焦作市| 宁强县| 桑植县| 淮安市| 晋州市| 呼玛县| 大兴区| 孟津县| 贺州市| 信丰县| 潞西市| 蕉岭县| 枞阳县| 焉耆| 金堂县| 云林县| 桦川县| 手游| 精河县| 石林| 忻州市| 灯塔市| 沂源县|