subject

You are given an array x of int elements along with an int variable n that contains the number of elements in the array. There are no duplicates in this array. You are also given an int variable m that has been declared. Assign to m the median value of the array. NOTE: The median of a set of numbers is the number in the set such that there are as many numbers above that value as there are below. If the set has an even number of members, the median is the average of the pair of numbers such that there are as many numbers above the pair as there are below. EXAMPLE 1: Given 5 8 1 9 7 the median is 7 because there are two numbers below (1 5) and two numbers above (8 9). EXAMPLE 2: Given 3 7 1 4 6 9 the median is the average of 4 and 6 because there are two numbers above 4 and 6 (7 9) and two numbers below (3 1). Were using myprogramminglab for homework now and for some reason it's not liking a lot of what I'm trying to turn in. For the question above my code is below. I through in a bubblesort so I could find the median but is still telling me my code is wrong. int *x;int n;int m;bool swap;int index, temp;x = new int [n];do{swap = false;for(int count=0; count<(n-1); count++){if(x[count] > x[count + 1]){temp = x[count];x[count]= x[count+1];x[count+1]= temp;swap = true;}}}while (swap);int index=0, m=0;if ((n%2) !=0){index = ((n - 1)/2);m = x[index];}else{index = ((n-1)/2);m = ((x[index] + x[index+1])/2);}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 16:00, nancylagunas805
What does josh silverman name as the most important aspect of managing finances?
Answers: 2
image
Computers and Technology, 22.06.2019 03:30, brin1021
Jessie has received a contract to build a real-time application for a baker. however, the baker doesn't want to invest too much money. his only requirement is that he wants the customers to know which cupcakes are available at what time and in what quantity. so his core requirement is that the details of product should be in real time. what platform can jessie use to develop this application?
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, lizz1228
Kto rozmawia z clamentain przez krótkofalówke w the walking dead w 4 epizodzie
Answers: 1
image
Computers and Technology, 23.06.2019 17:10, madams4450
Ac++an of of pi. in , pi is by : pi = 4 – 4/3 + 4/5 – 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 . ., to pi (9 ). , if 5 to pi, be as : pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 = 4 – 1. + 0.8 - 0. + 0. = 3.. atoofbe to pi?
Answers: 2
You know the right answer?
You are given an array x of int elements along with an int variable n that contains the number of el...

Questions in other subjects:

Konu
Mathematics, 22.11.2020 01:40
Konu
Mathematics, 22.11.2020 01:40