Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using  namespace  std;
  6. int main()
  7. {
  8.     string input;
  9.     cin>>input;
  10.     string year = input.substr(0, 2);
  11.     string month = input.substr(2, 2);
  12.     string date = input.substr(4, 2);
  13.     string gender;
  14.     int genderNum = input[8] - 48;
  15.     if (genderNum % 2 == 0)
  16.     {
  17.         gender = "male";
  18.     }
  19.     else
  20.     {
  21.         gender = "female";
  22.     }
  23.     int monthNum = (month[0] - 48) * 10 + (month[1] - 48);
  24.     int yearNum = (year[0] - 48) * 10 + (year[1] - 48);
  25.     if (monthNum > 40)
  26.     {
  27.         yearNum += 2000;
  28.         monthNum -= 40;
  29.     }
  30.     else
  31.     {
  32.         monthNum -= 20;
  33.         yearNum += 1900;
  34.     }
  35.     if (monthNum < 10)
  36.     {
  37.         cout<<"You are "<<gender<<" born on "<<date<<".0"<<monthNum<<"."<<yearNum<<endl;
  38.     }
  39.     else
  40.     {
  41.         cout<<"You are "<<gender<<" born on "<<date<<"."<<monthNum<<"."<<yearNum<<endl;
  42.     }
  43.  
  44. return 0;
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement