Monday, May 24, 2010

How to do it using arrays and or strings C++?

using Arrays and/or Strings





Enter 8 numbers and drop the lowest and highest and then adding the rest and output the score with two decimal places

How to do it using arrays and or strings C++?
The best place would be to start with the pseudo code version. Remember, an array is just a list of objects strung together (technically, a string is the same as a character array)


For simplicity, this assumes that you will not have a highest and lowest that appear multiple times.





try something like this


read in 8 numbers cycling through each one to fill up the array.


have 2 variables to store the current max and current min


begin processing through the array. the first item is both the highest and lowest number at this point.





move to the next number, if it's higher then the stored high number, change the stored high number to this one. (same thing on the other side if it's lower)





when you get to the end of the list you'll know which one is highest and which is lowest.








create a collector variable.


process all entries except for these 2 items adding each one to the total





hope this helps.
Reply:wow c++ that was freshman yr umm try puttin in order then comand to drop max and Min i forget that code sorry it dont help

flower girl dresses

No comments:

Post a Comment