c 輸入時間,和系統時間作比較

時間 2022-03-08 22:30:10

1樓:馮老師(必果學院

需要做一些合理的假設:

1 輸入時間採用這樣的格式 yyyy-mm-dd hh:mm:ss 即年月日.時分秒

2 系統時間是指本地(本時區的時間)

基於這些,**如下:

#include

#include

#include

int main()

else if(dayintm_year,p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);

return 0;

}//日期相等

tickin = hour*3600+min*60+sec;

ticksys = p->tm_hour*3600+p->tm_min*60+p->tm_sec;

if(tickin>ticksys)else//時間也相等

printf("time is equal!\n");

return 0;}

2樓:匿名使用者

#include

#include

int main()

}while(key!=2);

/////////////////////////////比較部分if (hour==timeinfo->tm_hour)if (minu==timeinfo->tm_min)else

}printf("system time is bigger!\n");

return 1; }}

3樓:

#include

#include

int main(void)

else if(compare.tm_hour==local->tm_hour)

else if(compare.tm_min==local->tm_min)

else if(compare.tm_sec==local->tm_sec)

else

}else

}else

printf("當前時間和日期: h:m:s %d:%d:%d\n",local->tm_hour,local->tm_min,local->tm_sec);

return 0;}

4樓:

hgmnj d f hfd

c++怎麼取當前時間和設定時間做比較?

5樓:周生

time_t timep;

struct tm *p;

time(&timep);

p = localtime(&timep); //取得當地時間printf ("%d%d%d ", (1900+p->tm_year), (l+p->tm_mon), p->tm_mday);

printf("%d%d:%d:%d\n", p->tm_wday, p->tm_hour, p->tm_min, p->tm_sec);

c++程式設計編寫乙個時間類time,包含時,分,秒資料成員實現時間的加,減,輸入和輸出,其中時

6樓:藍色**

#include

using namespace std;

class time

~time(){}

friend time operator+(time t1,time t2);

friend time operator-(time t1,time t2);

void operator=(time);

friend ostream& operator<<(ostream &,time);

friend istream& operator>>(istream &,time);

};int main()

while(t3.min>=60)

return t3;

}time operator-(time t1,time t2)

while(t3.min<0)

return t3;

}void time::operator=(time t)

ostream& operator<<(ostream &os,time t)

while(t.min>=60)

os<>(istream &is,time t)

c++程式設計 輸入數字轉換成對應的時間

7樓:唔知吳魏

首先說,這**寫的太冗餘了,最重要的是,你這**裡兩個表示分鐘的是什麼意思啊

#include

#include

using namespace std;

;ho=num[hours];

if(min<20)

else

} void main()

system("pause");}

C怎麼寫才能實時獲取時間,C 怎麼獲取系統時間並讓他隨時更新,就是能看見時間一秒一秒的往前走

datatime.now.tostring yyyy年m月d日hh mm 然後做個定時器,間隔時間1秒,定時執行這個語句, 在窗體上 timer控制元件,設定屬性enable ture 設定interval 1000.單位是毫秒。雙擊timer控制元件,在裡面寫label1.text datetim...

c語言有沒有讀取系統時間的函式,C語言有沒有讀取系統時間的函式

4.2 獲得日期和時間 這裡說的日期和時間就是我們平時所說的年 月 日 時 分 秒等資訊。從第2節我們已經知道這些資訊都儲存在乙個名為tm的結構體中,那麼如何將乙個日曆時間儲存為乙個tm結構的物件呢?其中可以使用的函式是gmtime 和localtime 這兩個函式的原型為 struct tm gm...

sql如何讀取系統日期和時間

getdate 函式從 sql server 返回當前的時間和日期。使用下面的 select 語句 select getdate as currentdatetime 結果 currentdatetime 2008 12 29 16 25 46.635 註釋 上面的時間部分精確到毫秒。例子 2 下面...