Find the maximum element in an array and sort the array with selection and bubbl
ID: 3642431 • Letter: F
Question
Find the maximum element in an array and sort the array with selection and bubble search methods.You will keep the position of the first and last element of your array with two pointers variables.These pointer variables will be kept in an array.In order to access the elements of input array, you will just use elements of this array, which is mentioned in,to sort this array and find maximum element.int *Asort(int input[]) All operation will be done in this function.
int *a, *b This pointers will keep first and last element index references
int *tum To swap the values, you will use this pointer
int **ter[2] This array will keep your input array first and last element index references
use only ter array to access the values of input array.
Explanation / Answer
Find Max. Num
#include
#include
#include
using namespace std;
int main()
{
const int arraySize = 10;
int myArray[arraySize];
int high = 0;
for(int i = 0; i < arraySize; ++i)
{
myArray[i] = rand()%10;
cout << myArray[i] << endl;
high = myArray[0];
if(myArray[i] > high)
high = myArray[i];
}
cout << " High: " << high << " ";
}
============================================================================
Sorting
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.