标签:names 输出时间 highlight mda str amp com style code
#include<iostream> #include <ctime> using namespace std; int main() { struct tm t1 = { 0 }; struct tm t2 = { 0 }; double seconds; t1.tm_year = 2019 - 1900; t1.tm_mon = 6; t1.tm_mday = 6;//现在时间2019,7,6 t2.tm_year = 2020 - 1900; t2.tm_mon = 5; t2.tm_mday = 7;//明年高考时间2020,6,7 seconds = difftime(mktime(&t2), mktime(&t1));//转换结构体为time_t,利用difftime,计算时间差 cout << "剩余天数: " << seconds / 86400 << endl;//最后输出时间,因为一天有86400秒(60*60*24) return 0; }
输出:
剩余天数: 337
转载:https://www.cnblogs.com/chechen/p/11143542.html
标签:names 输出时间 highlight mda str amp com style code
原文地址:https://www.cnblogs.com/xinhua219/p/12297881.html