Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4. int main()
  5. {
  6.     int ns,nn,tuoi; // ns: nam sinh; nn: nam nay
  7.     cout << "Nhap vao nam sinh: ";
  8.     cin >> ns;
  9.     time_t hientai=time(0); //lay thoi gian tu he thong
  10.     tm*ltm=localtime(&hientai);
  11.     nn=1900 + ltm -> tm_year; //chi lay nam tu he thong
  12.     cout << "Nam hien tai: " << nn << endl;
  13.     tuoi=nn-ns;
  14.     cout << "Tuoi hien tai: " << tuoi;
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement