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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. which step can possibly increase the severity of an incident? a. separating sensitive data from non-sensitive data b. immediately spreading the news about the incident response plan c. installing new hard disks d. increasing access controls
Answers: 2
question
Computers and Technology, 24.06.2019 07:30
Jason is working on a microsoft excel worksheet and he wants to create a print preview shortcut. his teacher asks him to access the customization option to create the new shortcut. which two tabs should jason select to place the print preview shortcut on the worksheet toolbar? a. new tab (custom) and new group (custom) b. new file tab (custom) and new tab (custom) c. new custom group and new command d. new custom tab and new command
Answers: 2
question
Computers and Technology, 25.06.2019 05:10
Write a program that asks for 'name' from the user and then asks for a number and stores the two in a dictionary (called 'the_dict') as key-value pair. the program then asks if the user wants to enter more data (more data (y/n)? ) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list. note: ignore the case where the name is already in the dictionary. example: name: pranshu number: 517-244-2426 more data (y/n)? y name: rich number: 517-842-5425 more data (y/n)? y name: alireza number: 517-432-5224 more data (y/n)? n [('alireza', '517-432-5224'), ('pranshu', '517-244-2426'), ('rich', '517-842-5425')]
Answers: 3
question
Computers and Technology, 25.06.2019 15:00
Apart from confidential information, what other information does nda to outline ?
Answers: 1
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
question
History, 27.11.2019 23:31
question
Mathematics, 27.11.2019 23:31
Questions on the website: 13722360