C language · Score statistics

Source: Internet
Author: User

Algorithm increases fractional statistical time limit: 1.0s memory limit: 512.0MBThe problem description was updated in 2016.4.5, and the previous procedure needed to be resubmitted. Problem description Given a percentile score T, divide it into one of the following five levels:
90~100 for a,80~89 to b,70~79 for c,60~69 to d,0~59 for E
Now given a file of INP, the file contains several percentile scores (no more than 100 scores), please count the number of people in five tiers, and find out the number of the highest level segment, according to the order from large to small output in this paragraph of the total score (only one of the maximum number of people). Requires output to the specified file OUP. Input format a positive integer of several 0~100, separated by a space the output format first behavior 5 positive integers, each representing a,b,c,d,e five levels of the number of people
The second line is a positive integer representing the largest number of people in the hierarchy
The next line is a number of positive integers separated by spaces, which represent the scores of all people in the highest rank, output in order from large to small. Example input 100 80 85 77 55 61 82 90 71 60 Sample Output 2 3 2 2 1
3
85 82 80 Author Note: The Blue Bridge Cup is actually compiled with a n--table that inputs n 0~100 positive integers as fractions. Correct code:
1#include <algorithm>2#include <iostream>3#include <string.h>4 intnum[1005]; 5 using namespacestd; 6 intMain ()7 {  8     intN,i =0, sum; 9     inttemp[5][1005],dp[5] = { -, the, -, -,0}; Tenmemset (temp,0,sizeof(temp));  OneCin>>sum;  A      for(; I < sum;i++)   -     {   -Cin>>Num[i];  the          for(intj =0; J <5; j + +)   -         {   -             if(Num[i] >=Dp[j]) -             {   +temp[j][++temp[j][0]] =Num[i];  -                  Break;  +             }   A         }   at     }   -     intMAXN =0, Maxl =0;  -      for(intt =0; t <5; t++)   -     {   -cout<<temp[t][0]<<" ";//number of people who output each level -         if(Maxn < temp[t][0])   in         {   -MAXN = temp[t][0];  toMAXL =T;  +         }   -     }   thecout<<endl<<maxn<<Endl;  *Sort (temp[maxl]+1, temp[maxl]+temp[maxl][0]+1);  $      for(intt = temp[maxl][0];t >=1; t--)  Panax Notoginsengcout<<temp[maxl][t]<<" ";  -     return 0;  the}
Error code:
1#include <stdio.h>2 intMain () {3     intN;4     intA=1, b=1, c=1, d=1, e=1;5scanf"%d",&n);6     intScore[n];7     inta1[5][n];8      for(intI=0;i<5; i++){9a1[i][0]=0;Ten     } One      for(intI=0; i<n;i++){ Ascanf"%d",&score[i]); -         if(score[i]>= -){ -a1[0][a]=Score[i]; thea1[0][0]++; -a++; -         } -         Else if(score[i]>= the&& score[i]< -){ +a1[1][b]=Score[i]; -a1[1][0]++;  +b++; A         } at         Else if(score[i]>= -&& score[i]< the){ -a1[2][c]=Score[i]; -a1[2][0]++; -C++; -         } -         Else if(score[i]>= -&& score[i]< -){ ina1[3][d]=Score[i]; -a1[3][0]++;  tod++; +         } -         Else if(score[i]< -){ thea1[4][e]=Score[i]; *a1[4][0]++; $e++;Panax Notoginseng         } -     } theprintf"%d %d%d%d%d\n", a1[0][0],a1[1][0],a1[2][0],a1[3][0],a1[4][0]); +      A     /*bubble Descending for each number of levels*/ the      for(intI=0; i<5-1; i++){ +          for(intj=0; j<5-1-I.; J + +){ -             /*Descending*/ $             if(a1[j][0]<a1[j+1][0]){ $                 intt = a1[j][0]; -a1[j][0] = a1[j+1][0]; -a1[j+1][0] =T; the             } -         }Wuyi     } theprintf"%d\n", a1[0][0]); -      for(intI=1; i<=a1[0][0];i++){ Wuprintf"%d", a1[1][i]); -     } About}

C language/score statistics

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.