Advertisement
Morogn93

Untitled

Oct 21st, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <time.h>
  2.  
  3. #include <iostream>
  4.  
  5. int main()
  6. {
  7.     using namespace std;
  8.    
  9.     int birthData;
  10.     time_t theTime = time(NULL);
  11.     struct tm *aTime = localtime(&theTime);
  12.    
  13.     int day = aTime->tm_mday;
  14.     int month = aTime->tm_mon + 1; // Month is 0 - 11, add 1 to get a jan-dec 1-12 concept
  15.     int year = aTime->tm_year + 1900;
  16.    
  17.     cout<<"Podaj date urodzenia\n";
  18.     cin >>birthData;
  19.     cout<<year<<endl;
  20.     int DataUrodzenia = year-birthData;
  21.     cout<<DataUrodzenia<<endl;
  22.    
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement