题目描述
八尾勇喜欢吃苹果。她今天吃掉了 xxx 个苹果。英语课上学到了 apple 这个词语,想用它来造句。如果她吃了 1 个苹果,就输出 Today, I ate 1 apple.;如果她没有吃,那么就把 1 换成 0;如果她吃了不止一个苹果,别忘了 apple 这个单词后面要加上代表复数的 s。你能帮她完成这个句子吗?
输入格式
输入一行一个自然数 xxx,表示吃掉的苹果数。
输出格式
根据题目要求输出。
样例输入
1
样例输出
Today, I ate 1 apple.
样例输入
3
样例输出
Today, I ate 3 apples.
提示
对于所有数据,0≤x≤1000\le x \le 1000≤x≤100。
参考代码
#include<iostream>
using namespace std;
int main() {
int x;
cin >> x;
//注意输出格式,单词间的空格不能丢
cout << "Today, I ate ";
if(x > 1) cout << x << " apples.";
else cout << x << " apple.";
return 0;
}

该编程题要求读入一个自然数x,表示八尾勇吃的苹果数,然后输出相应的英文句子。如果x为1,输出Today,Iate1apple.;若x大于1,则输出Today,Iatexapples.,其中x是实际的苹果数量。程序需处理0到100之间的苹果数。
761

被折叠的 条评论
为什么被折叠?



