2884: Fruit Grading

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 70   Solved: 64
[ Submit ][ Status ][ Web Board ]

Description

The standard for the purchase of oranges from a certain origin is to determine the grade of oranges according to the maximum cross-sectional diameter of the oranges. >=85 is the first-class fruit, >=75 and <85 is the second-class fruit, >=65 and <75 is the third-class fruit, < 65 is the fourth grade fruit. Given the diameters of n oranges, please give the number of oranges of each grade according to the classification criteria.

There is a lack of code between the line where begin is located and the line where end is located. Please complete the entire program based on the following code. When submitting, only submit the code between the line where begin is located and the line where end is located.

#include <iostream>
using namespace std;

int  main()
{
    int  n1=0, n2=0, n3=0, n4=0;
    int  i, n, diameter;

    cin>>n;     //Enter the number of oranges

    for(i=1; i<=n; i++)
    {
       cin>>diameter;  
//Enter the maximum cross-sectional diameter of the orange

      //begin

 

        //end 

     }

    cout<<"1:"<<n1<<endl;
    cout<<"2:"<<n2<<endl;
    cout<<"3:"<<n3<<endl;
    cout<<"4:"<<n4<<endl;

   return 0;
}

Input

The total number of tangerines and the maximum cross-sectional diameter of each tangerine

Output

Number of first-class fruits

Number of secondary fruits

Number of tertiary fruits

Sample Input

10
90 88 76 85 60 65 75 68 73 84

Sample Output

1:3
2:3
3:3
4:1

HINT

When submitting, only submit the code between the line where begin is located and the line where end is located

Source

gyy



Code:

#include <iostream>
 using namespace std;


int  main()
 {
     int  n1=0, n2=0, n3=0, n4=0;
     int  i, n, diameter;


    cin>>n;     //输入橘子个数


    for(i=1; i<=n; i++)
     {
        cin>>diameter;   //输入橘子最大横切面直径


      if(diameter>=85)n1++;
      else if(diameter<85&&diameter>=75)n2++;
      else if(diameter<75&&diameter>=65)n3++;
      else n4++;


     }


    cout<<"1:"<<n1<<endl;
     cout<<"2:"<<n2<<endl;
     cout<<"3:"<<n3<<endl;
     cout<<"4:"<<n4<<endl;
   return 0;
 }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325725417&siteId=291194637