溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

庫函數調用之時間的顯示、計算、應用

發布時間:2020-08-16 16:20:30 來源:網絡 閱讀:412 作者:TheRoodToDeath 欄目:軟件技術

                                                            時間類型
UTC世界時間
日歷時間
從1970年1月1日
#include<stdio.h>
struct tm *gmtime(const time_t*timep)
功能;將日歷時間轉化格林威志時間;
struct tm{

int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year; //tm_year +1900=哪一年
int tm_wday;
int tm_yday;
int tm_isdst;

}
#include<time.h>
#include<stdio.h>
int main(void){
struct tm *local;
time_t t;
t=time(NULL);
local=localtime(&t);
printf("local hour time:%d\n",loccal->tm_hour);
local=gmtime(&t);
printf("utc hour is :%d/n",local->tm_hour);return 0;

}

獲取時間
int gettimeofday(struct timeval *tv,struct timezone tz*)
功能;獲取從今日凌晨到現在的時差

struct timeval{


int tv_sec; //miao
int tv_usec;//wei miao


};

#include<sys/time.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

 

/************時間函數,延遲函數****************/
void function()
{
 unsigned int i,j;
 double y;
 for(i=0;i<1000;i++)
 for(j=0;j<1000;j++)
 j++;

}

/*******此函數可以計算出一個函數運行的時間********/
main()
{
struct timeval tpstart ,tpend;
float timesuel
gettimeofday(&tpstat,NULL);              // time of start
function();
gettimeofday(&tpend,NULL);              //count time end ;
/*count  time*/

timeuse=1000000*(tpend.tv_sec-tpstart.tv_set);
printf("used time ;\n",timeuse);
exit(0);
}


 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女