Feb 14, 2012 at 1:49am Feb 14, 2012 at 1:49am UTC
change the condition of 'k' in the 'for cicle':
//(k=i+1;k>0;--k) ----> to ----> (k=i+1;k<num;k++)
and
1 2 3 4 5 6 7 8 9 10 11 12 13
//change this
if (Array[i] < Array[i-1]){
int temp = Array[i];
Array[i] = Array[i-1];
Array[i - 1] = temp;
}
//to this
if (Array[i] > Array[k]){
int temp = Array[i];
Array[i] = Array[k];
Array[k] = temp;
}
Last edited on Feb 14, 2012 at 1:54am Feb 14, 2012 at 1:54am UTC
Feb 14, 2012 at 2:01am Feb 14, 2012 at 2:01am UTC
Also your sum code wont work like you want it to.
At the moment the sum is equal to whatever the last number of the array entered was + b (b is always equal to 0 in this case).
Change line 38 to
sum += Array[i]
That will add each element of the array to the sum each time it loops.