Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Задание 2. Мой возраст
- */
- #include <iostream>
- #include <locale>
- using namespace std;
- string getRightWord(int age) {
- if (5 <= age && age <= 20) {
- return "лет";
- }
- int last_age_digit = age % 10;
- if (last_age_digit == 1) {
- return "год";
- } else if (2 <= last_age_digit && last_age_digit <= 4) {
- return "года";
- } else {
- return "лет";
- }
- }
- int main() {
- setlocale(LC_ALL, "Russian");
- int age;
- cin >> age;
- cout << "Мне " << age << " " << getRightWord(age);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement