洛谷-P5712 【深基3.例4】Apples

洛谷-P5712 【深基3.例4】Apples

原题链接:https://www.luogu.com.cn/problem/P5712


题目描述

八尾勇喜欢吃苹果。她今天吃掉了 (x(0le x le 100)) 个苹果。英语课上学到了 apple 这个词语,想用它来造句。如果她吃了 1 个苹果,就输出 Today, I ate 1 apple.;如果她没有吃,那么就把 1 换成 0;如果她吃了不止一个苹果,别忘了 apple 这个单词后面要加上代表复数的 s。你能帮她完成这个句子吗?

输入格式

输出格式

输入输出样例

输入 #1

1

输出 #1

Today, I ate 1 apple.

输入 #2

3

输出 #2

Today, I ate 3 apples.

C++代码

#include <iostream>
using namespace std;

int main() {
    int x;
    cin >> x;
    cout << "Today, I ate " << x;
    if (x <= 1)
        cout << " apple." << endl;
    else
        cout << " apples." << endl;
    return 0;
}
原文地址:https://www.cnblogs.com/yuzec/p/13328561.html