Ciao a tutti, ho fatto questo problema ma in alcuni casi mi da dei problemi, mi sapreste dire cosa ho sbagliato, grazie mille!!
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int N,i,arr[N],p,arr2[N],min=0,mag;
srand(time(NULL));
cout << "quanti numeri vuoi inserire?" << endl;
cin >> N;
for(i=0;i<N;i++)
{
arr[i]=rand()%100;
}
cout << endl <<endl;
for(i=0;i<N;i++)
{
cout << arr[i] << "\t";
}
cout << endl <<endl;
p=rand()%N;
mag=(N-1);
for(i=0;i<N;i++)
{
if(arr[i]<=arr[p]&&i!=p)
{
arr2[min]=arr[i];
min++;
}
else if(arr[i]>=arr[p]&&i!=p)
{
arr2[mag]=arr[i];
mag--;
}
else if(i==p)
{
continue;
}
}
arr2[min]=arr[p];
cout << endl <<endl;
for(i=0;i<N;i++)
{
cout << arr2[i] << "\t";
}
cout << endl <<endl;
return 0;
}