0

hi im new to c++ and at the moment trying to write a program that generates random numbers and then sorts those numbers using bubblesort. So far ive managed to get the random numbers working but i am unable to sort the random numbers with bubblesort ?

```
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int min, max, rsize;
cout << "enter the amount of numbers wanted: ";
cin >> rsize; // array size
cout << "enter minimum: ";
cin >> min;
cout << "enter maximum: ";
cin >> max;
if (min > max) {
cout << "your minium value is greater than maximum, it is now swapped" << endl;
cout << "your array: " << endl;
int temp = min;
min = max;
max = temp; }
//int range = max - min + 1;
max = max - min;
++max;
srand( time(NULL) );
int r;
for (int i = 0; i < rsize; i++)
{r = rand() % max + min; // the random numbers = r
const int w = r;
cout << w <<" ";
}
cout << endl;
{
double temp2, marker;
int j;
const int p = rsize;
double a [p];
for (j=0; j<p; j++){
a[j];
a[j] = r
}
for (marker=p; marker>1; marker--){
j = 1;
for (j=0; j<p; j++) {
if(a[j] < a[j-1]){
temp2 = a[j-1];
a[j-1] = a[j];
a[j] = temp2;
j++;
}
}
}
for (j=0; j<p; j++){
cout << a[j] << " "; // this will print the sorted numbers
}
system("pause"); // this is used otherwise the program begins then just suddenly terminates
return 0;
}
```