#include <iostream>
using namespace std;
int main()
{
int i, x, j, t;
int size = rand() % 100;//random number
int a[size];// random number is the size of array
//array filling
for (i = 0; i <= size; i++) {
a[i] = rand() % 100;//new random number -> gets assigned as part of the array
}
for (x = 0; x < size; x++) {
for (j = x + 1; j < size; j++)
{
if (a[j] < a[x]) { //if x > x+1 sortieren
t = a[x];
a[x] = a[j];
a[j] = t;
}
}
}
for (x = 0; x < size; x++) {
cout << a[x] << "\t";
}
return 0;
}
Array declaration not working for me but its working for my colleague. It seems that the IDE insists that the array has to be a constant.