C – Counting Numbers {making a program} [closed]

If I understand the requirements, your input looks something like this:

3
5 90 91 75 34 78
4 20 20 45 78
6 87 44 73 91 91 90

You have 3 test cases: test case 1 gives the scores for 5 students, test case two gives the scores for 4 students, and test case 3 gives the scores for 6 students.

For each test case, you print out the maximum score and the number of times that score appears:

Test case 1: max score = 91, number of students = 1 out of 5
Test case 2: max score = 78, number of students = 1 out of 4
Test case 3: max score = 91, number of students = 2 out of 6

or something along those lines.

So, you need to think in terms of the following operations:

  1. Get the number of test cases
  2. For each test case, get the number of scores
  3. Read the scores
  4. Determine the max score, and the number of times that score appears
  5. Print the result for that test case
  6. Go back to 2

You should not need to use any arrays for this; you only need to keep track of the maximum score and the number of times you’ve seen it for any given test case.

Now, if you have a specific problem with any of the above steps, please ask, and we’ll do what we can to steer you in the right direction. But nobody’s going to write your code for you. You have to show us what you’ve done.

Browse More Popular Posts

Leave a Comment