ex11-09.cpp

来自「数据结构常用算法合集」· C++ 代码 · 共 30 行

CPP
30
字号
//EX11-09.cpp
#include <iostream.h>	//cout,cin
#include <conio.h>		// getch()
#include <time.h>			//time()
#include <dos.h>			//date
void main()
{ time_t current_s,birthday_s;
  date current,birth;
  int mon,day;
  current_s = time(NULL);
  getdate(&current);	 //get current date
  cout << "Current date is:";
  cout << current.da_year<<' '
       <<(int)current.da_mon<<' '
       <<(int)current.da_day<<endl;
  cout << "Enter year(after 1980),month,day:";
  cin >> birth.da_year
      >> mon
      >> day;
  birth.da_mon=char(mon);
  birth.da_day=char(day);
  setdate(&birth);
  birthday_s = time(NULL);
  cout << "The seconds from your birth to now are:"
       << (current_s - birthday_s);
  setdate(&current);	//set current date back
  getch();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?