Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- int ns,nn,tuoi; // ns: nam sinh; nn: nam nay
- cout << "Nhap vao nam sinh: ";
- cin >> ns;
- time_t hientai=time(0); //lay thoi gian tu he thong
- tm*ltm=localtime(&hientai);
- nn=1900 + ltm -> tm_year; //chi lay nam tu he thong
- cout << "Nam hien tai: " << nn << endl;
- tuoi=nn-ns;
- cout << "Tuoi hien tai: " << tuoi;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement