Nanyang acm-50-love to Pick apples Xiao Ming (water problem)

Source: Internet
Author: User

Love picking apples time limit:MS | Memory limit:65535 KB Difficulty:1
Describe
There is an apple tree in the yard of Xiao Ming's house, and 10 apples will be produced in every fall tree. When Apple matures, Xiaoming will run to pick apples. Xiao Ming has a 30 cm high bench, when she can not directly pick the apples by hand, will step on the bench and try again.
Now that you know the height of 10 apples to the ground, and the maximum height that xiaoming can reach when you straighten your hand, please help Xiao Ming calculate the number of apples she can pick. If she touches an apple, the Apple will fall.
Input
the first line of input N (0<n<100) represents the number of test data groups, followed by two rows of data for each set of test inputs. The first line contains 10 integers from 100 to 200 (including 100 and 200), each representing 10 apples to the ground height, and two adjacent integers separated by a space. The second line contains only an integer (in centimeters) between 100 and 120 (containing 100 and 120), indicating the maximum height that xiaoming can reach when the hand is straightened.
Output
The
output includes one row, which contains only an integer that indicates the number of apples that xiaoming can pick up.
Sample input
1100 200 150 140 129 134 167 198 200 111110
Sample output
5


Solving:

#include <stdio.h>//himself made the AC
int main ()
{
int N;
scanf ("%d", &n);
while (n--)
{
int q,w,e,r,t,y,u,i,o,p,a,n;
int s=0;
scanf ("%d%d%d%d%d%d%d%d%d%d", &q,&w,&e,&r,&t,&y,&u,&i,&o,&p);
scanf ("%d", &n);
a=n+30;
if (a>=q)
s++;
if (a>=w)
s++;
if (a>=e)
s++;
if (a>=r)
s++;
if (a>=t)
s++;
if (a>=y)
s++;
if (a>=u)
s++;
if (a>=i)
s++;
if (a>=o)
s++;
if (a>=p)
s++;
printf ("%d\n", s);
}

return 0;
}
#include <iostream>//Optimal Problem Solving program
using namespace Std;
int main ()
{
int s,i,a[10],t,m;
cin>>s;
while (s--)
{
t=0;
for (i=0;i<10;i++)
cin>>a[i];
cin>>m;
for (i=0;i<10;i++)
if (a[i]<=m+30) t++;
cout<<t<<endl;
}
return 0;
}

Nanyang acm-50-love to Pick apples Xiao Ming (water problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.