Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int birth_day, birth_month, birth_year;
- int current_day, current_month, current_year;
- cout << "Введите дату рождения: ";
- cin >> birth_day >> birth_month >> birth_year;
- cout << "Введите текущую дату: ";
- cin >> current_day >> current_month >> current_year;
- int age = current_year - birth_year;
- if (current_month < birth_month || (current_month == birth_month && current_day < birth_day)) {
- age--;
- }
- cout << "Вам " << age;
- if (age % 10 == 1 && age % 100 != 11) {
- cout << " год";
- } else if (age % 10 >= 2 && age % 10 <= 4 && (age % 100 < 10 || age % 100 >= 20)) {
- cout << " года";
- } else {
- cout << " лет";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment