9-degree OJ 1018 count the number of students with the same score, oj1018

Source: Internet
Author: User

9-degree OJ 1018 count the number of students with the same score, oj1018

Question 1018: count the number of students with the same score

Time Limit: 1 second

Memory limit: 32 MB

Special question: No

Submit: 6337

Solution: 3419

Description:
Reads the scores of N students and outputs the number of students who have obtained a given score.
Input:
The test input contains several test cases. The format of each test case is


Row 3: N
Row 2nd: scores of N students. Two Adjacent numbers are separated by a space.
Row 3rd: Given score

When N = 0 is read, the input ends. Where N does not exceed 1000, and the score is an integer (including) between 0 and 100.
Output:
For each test case, the number of students with a given score is output.
Sample input:
380 60 9060285 660560 75 90 55 75750
Sample output:
102
#include<stdio.h>int a[1001];int main(int argc, char *argv[]){    int N;    while(~scanf("%d",&N))    {        if(N==0)return 0;        for(int i=0;i<N;++i)            scanf("%d",&a[i]);        int num;        int cnt=0;        scanf("%d",&num);        for(int i=0;i<N;++i)            if(a[i]==num)            {                cnt++;            }        printf("%d\n",cnt);    }    return 0;} /**************************************************************    Problem: 1018    User: kirchhoff    Language: C    Result: Accepted    Time:10 ms    Memory:916 kb****************************************************************/



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.