其他分享
首页 > 其他分享> > 【洛谷】【分支】Apples

【洛谷】【分支】Apples

作者:互联网

题目描述

八尾勇喜欢吃苹果。她今天吃掉了 x(0≤x≤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.
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int  main(){
	int x;
	cin>>x;
	if(x ==0 || x == 1){
		cout<<"Today, I ate "<<x<<" apple.";
	}
	else
		cout<<"Today, I ate "<<x<<" apples.";

	return 0; 
}

标签:ate,洛谷,apple,苹果,复制,Apples,include,Today,分支
来源: https://blog.csdn.net/weixin_48180029/article/details/111387298