- #1
Litcyb
- 36
- 0
C++-- while-loop
calculate the 3 largest number of a sequence
you ask the user to input a sequence of numbers, and enter the value 0 to stop entering numbers.
c++
i managed to calculate the the maximum of the series of numbers, i don't know how i can calculate the 2nd max and the 3rd max number. please help.
cin>>value;
while(count > 0)
{
cin>> input;
if (input==0)
{
cout<<"sequence ended"<<endl;
break;
}
else if(input > value)
{
input= value;
}
count++;
this will generate the Maximum, how can i calculate the second max and 3rd max.
Homework Statement
calculate the 3 largest number of a sequence
Homework Equations
you ask the user to input a sequence of numbers, and enter the value 0 to stop entering numbers.
c++
The Attempt at a Solution
i managed to calculate the the maximum of the series of numbers, i don't know how i can calculate the 2nd max and the 3rd max number. please help.
cin>>value;
while(count > 0)
{
cin>> input;
if (input==0)
{
cout<<"sequence ended"<<endl;
break;
}
else if(input > value)
{
input= value;
}
count++;
this will generate the Maximum, how can i calculate the second max and 3rd max.