Question
Sorry Array with Pointers Read this explanation on bubble sorting https://goo.gl/PpRFM7 Then write a bubble sort to sort the following array from highest to smallest
Sorry Array with Pointers
Read this explanation on bubble sorting
https://goo.gl/PpRFM7
Then write a bubble sort to sort the following array from highest to smallest
int x[5] = {4,57,10,11,62};
using the pointers p1, p2 to do the sorting
int *p1 = x;
int *p2 = x+1;
The output should look like
Original: 4 57 10 11 62
Sorted: 62 57 11 10 4
Starter Code
#include
using namespace std;
int main() {
int x[5] = {4,57,10,11,62};
int *p1 = x;
int *p2 = x+1;
int temp;
bool check;
cout << "Original: ";
for (int i=0; i < 5; i++)
cout << *(x+i) << " ";
cout << endl;
do
{
// your code here
}while (check);
cout << "Sorted: ";
for (int i=0; i < 5; i++)
cout << *(x+i) << " ";
cout << endl;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started