How to count some repetitions

N

nick048

Hi,
I am a new user of C++ and I am learning this language.
I want to resolve this example:
1) I have an indefinite sequence of integer (from 0 to 36) as Input;
2) I want to know the maximum number of occurrences and its value.
eg Input: 0, 2, 5, 2, 23, 11, 11, 23, 15, 17, 25, 11, 23, 18, 23
(Ctrl+z)
Output: Value is 23 Occurences is 4

For the input I have written this code:
iNumber = 0; // Counter
while (1)
{ //read next
cout << "Enter number (Ctrl-z = Input End): ";
cin >> myNumber;
if (cin.eof())
break;
//update the counter
iNumber++;
}

But I am in difficulty, when I try to resolve the second step. The
solution don't have to use the array.

I hope in Your help in order to resolve my problem without array or map
or struct.

Thank You and Best Regards
Nino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top