当前位置:网站首页>Luogu Taotao picks apples
Luogu Taotao picks apples
2022-07-27 08:14:00 【Bamboo monk-】
Title Description
There is an apple tree in the Tao Tao's yard , Every autumn the trees will bear 10 An apple . When the apple is ripe , Tao Tao would run to pick apples . Tao Tao has a 30 Centimeter high bench , When she can't pick the apple directly by hand , Will step on the bench and try again .
Now we know 101 The height of an apple to the ground , And the maximum height that can be reached when the handle of pottery is extended , Please help Tao Tao calculate the number of apples she can pick . Suppose she ran into an apple , The apple will fall .
Input format
The input consists of two lines of data . The first line contains 10 individual 100 To 200 Between ( Include 100 and 200 ) The integer of ( In centimeters ) respectively 10 The height of an apple to the ground , Two adjacent integers are separated by a space . The second line only includes one 100 To 120 Between ( contain 100 and 120) The integer of ( In centimeters ), It means the maximum height that can be reached when the handle of pottery is extended .
Output format
The output includes a line , This line contains only one integer , The number of apples that pottery can pick .
Input and output
Input
100 200 150 140 129 134 167 198 200 111 110
Output
5
Examine the subject : Take turns typing 10 Apple height , Then with Tao Tao's height +30 Compare , If it is less than , Just res+1.
step :
1. Defining variables
int a[15],n,ans=0;
2. Enter the apple height
for(int i=1;i<=10;i++)
{
cin>>a[i];
} 3. Enter the height 、 Compare
cin>>n;
for(int i=1;i<=10;i++)
{
if(n+30>=a[i])
ans++;
}Output :
cout<<ans<<endl;Complete code :
#include<iostream>
using namespace std;
int a[15],n,ans=0;
int main()
{
for(int i=1;i<=10;i++)
{
cin>>a[i];
}
cin>>n;
for(int i=1;i<=10;i++)
{
if(n>=a[i] || (n+30)>=a[i])
ans++;
}
cout<<ans<<endl;
return 0;
}Novice , I would appreciate your comments.
边栏推荐
- C language: random generated number + insertion sort
- Idea remote debugging
- An ordinary autumn recruitment experience
- Grandson's questions are difficult, and his son's invigilation is strict. I can't do it. Pay back my school money
- [geek challenge 2019] finalsql 1
- idea远程调试
- Plato farm is expected to further expand its ecosystem through elephant swap
- pytorch_ demo1
- How to log in multiple wechat on the computer
- Use of "PHP Basics" Boolean
猜你喜欢

Record a PG master-slave setup and data synchronization performance test process

Internet of things industrial UART serial port to WiFi to wired network port to Ethernet Gateway WiFi module selection

Demo:st05 find text ID information

Notes in "PHP Basics" PHP

redis配置文件下载

Use of string type "PHP Basics"

虚拟机克隆

如何更新pip3?和Running pip as the ‘root‘ user can result in broken permissions and conflicting behaviour

Lua iterator

QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform
随机推荐
Things come to conform, the future is not welcome, at that time is not miscellaneous, neither love
瑞芯微RK3399-I2C4挂载EEPROM的修改案例
北京五日游记
Want the clouds in the picture to float? Video editing services can be achieved in three steps with one click
这次龙蜥展区玩的新花样,看看是谁的 DNA 动了?
想让照片中的云飘起来?视频编辑服务一键动效3步就能实现
Shenzhi Kalan Temple
The dragon lizard exhibition area plays a new trick this time. Let's see whose DNA moved?
Lua stateful iterator
What is a rebound shell? What's the use of bouncing shells?
npm的使用
You may need an additional loader to handle the result of these loaders.
软件调优方法有哪些?看看飞腾技术专家怎么说 | 龙蜥技术
Abstract factory pattern
Database startup report error_ user_ connect_ times &gt; 0 error
How to log in multiple wechat on the computer
Grandson's questions are difficult, and his son's invigilation is strict. I can't do it. Pay back my school money
Leetcode56. Consolidation interval
kalibr标定realsenseD435i --多相机标定
阿里云国际版回执消息简介与配置流程