當前位置:編程學習大全網 - 網站源碼 - C++ 調用系統函數計算年齡

C++ 調用系統函數計算年齡

#include <iostream>

#include <ctime>

using namespace std;

int main()

{

time_t timer;

struct tm* t_tm;

time(&timer);

t_tm=localtime(&timer);

int year=t_tm->tm_year+1900,

month=t_tm->tm_mon+1,

day=t_tm->tm_mday;

int y,m,d;

cin>>y>>m>>d;

if(month<m||month==m&&day<d) cout<<year-y-1<<endl;

else cout<<year-y<<endl;

return 0;

}

  • 上一篇:要在torch上安裝opencv嗎?
  • 下一篇:拼多多貨到付款怎麽操作
  • copyright 2024編程學習大全網