### problem with my array help please

I'm having difficulty implementing the mean/median/max/min.
I get the fact that the first in my sorted would be the min, but how would i get the max if its based on user control so i don't know what the last one is?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172`` ``````#include using namespace std; void sort (double x[], int length) { bool continueSort = true; int i; double temp; while (continueSort == true) { continueSort = false; for (i=0;i< length-1; i++) { if (x[i] > x [i+1]) { temp = x [i]; x[i] = x[i+1]; x[i+1] = temp; continueSort = true; } } } } int main() { int i,scoreCount,sum=0; double mean, median, min, max; cout << "Enter Score Count <1-20> "; cin >> scoreCount; if (scoreCount >= 1 && scoreCount <= 20) { double x[scoreCount]; for (i=0;i> x[i]; sum = sum + x[i]; } cout << "Original Data: "<< endl; for (i=0;i
max:
`x[?]` => `x[scoreCount - 1]`

median:
 ``1234`` ``````#include /*...*/ int middle = scorecount / 2; median = (scoreCount%2) ? x[middle] : ((x[middle] + x[middle+1]) / 2);``````

 ``12`` ``````cin >> scoreCount; double x[scoreCount];``````
This is not standard C++ and should not work. I recommend to turn off your compiler extension which allows this.

Last edited on
Topic archived. No new replies allowed.