rishat06

2_11

Sep 16th, 2025
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | Source Code | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int birth_day, birth_month, birth_year;
  6.     int current_day, current_month, current_year;
  7.    
  8.     cout << "Введите дату рождения: ";
  9.     cin >> birth_day >> birth_month >> birth_year;
  10.     cout << "Введите текущую дату: ";
  11.     cin >> current_day >> current_month >> current_year;
  12.    
  13.     int age = current_year - birth_year;
  14.    
  15.     if (current_month < birth_month || (current_month == birth_month && current_day < birth_day)) {
  16.         age--;
  17.     }
  18.    
  19.     cout << "Вам " << age;
  20.    
  21.     if (age % 10 == 1 && age % 100 != 11) {
  22.         cout << " год";
  23.     } else if (age % 10 >= 2 && age % 10 <= 4 && (age % 100 < 10 || age % 100 >= 20)) {
  24.         cout << " года";
  25.     } else {
  26.         cout << " лет";
  27.     }
  28.    
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment