•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,666 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,641 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 3601 | Replies: 6 | Solved
![]() |
•
•
Join Date: Oct 2004
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
I have to write a program for homework that asks for contestant scores, then outputs the total after the lowest and highest number are deleted. This is what I have so far. I can't use a sort since we haven't covered that yet and I'm not sure exactly how to subtract the lowest and highest number without sorting. Any help is much appreciated.
Thanks!
Thanks!
#include <iostream>
using namespace std;
int main()
{
int counter;
double sum;
double data [8];
cout<<"Enter data: ";
for (counter = 0; counter < 8; counter++)
data[counter] = 0.0;
for (counter = 0; counter < 8; counter++)
cin>>data[counter];
sum = 0;
for (counter = 0; counter < 8; counter++)
sum = sum + data[counter];
cout<<endl;
cout<<"Total points = "<<sum<<endl;
return 0;
}•
•
Join Date: Nov 2004
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 1
I think you can do the following:
Define MAX as the maximum of the scores. First set it as equal to the first element of the array of scores. Then compare successively MAX with the elements of the array. Set MAX as equal to the particular element if MAX is less than the element; otherwise, proceed to compare MAX with the next element.
The minimum MIN of the scores can likewise be obtained.
Finally, of course, just substract MAX and MIN from the sum.
Define MAX as the maximum of the scores. First set it as equal to the first element of the array of scores. Then compare successively MAX with the elements of the array. Set MAX as equal to the particular element if MAX is less than the element; otherwise, proceed to compare MAX with the next element.
The minimum MIN of the scores can likewise be obtained.
Finally, of course, just substract MAX and MIN from the sum.
•
•
Join Date: Nov 2004
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 1
No, I mean insert the following code into yours after the data are entered:
MAX = MIN = data[0];
for (counter = 1; counter < 8; counter++)
{
if (data[counter]>MAX) MAX = data[counter];
if (data[counter]<MIN) MIN = data[counter];
}
MAX = MIN = data[0];
for (counter = 1; counter < 8; counter++)
{
if (data[counter]>MAX) MAX = data[counter];
if (data[counter]<MIN) MIN = data[counter];
}
•
•
•
•
Originally Posted by KittyGirl
Is this what you mean?
while (max > 0.0 || max <= 10.0)
•
•
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,480
Reputation:
Rep Power: 8
Solved Threads: 98
•
•
•
•
Originally Posted by sosy2001
Hello Kitty,
can you help with with my array question? I need to store the users input into an array, then sum the numbers and then print them out in reverse.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- min/max of a mixed type list (Python)
- min and max values (C++)
Other Threads in the C++ Forum
- Previous Thread: Counting the amount of different words with vectors?
- Next Thread: Can I make my C program understand that a key has been pressed?



Linear Mode