Volevo un aiuto per il codice seguente DUPLICATO MANCANTE
#include <math.h>
#include <algorithm>
using namespace std;
int trova(int N, int P[])
{int mancante=0;
sort(P,P+(2*N-1)); //ORDINO L'ARRAY
for (int i=0;i<2*N-1;i=i+2) // CONTROLLO OGNI COPPIA
{ if (P[i]!=P[i+1]) // SE TROVO UNA COPPIA DOVE
// GLI ELEMENTI NON COINCIDONO
{ mancante =P[i];
i=2*N; // ESCO DAL CICLO
}
}
return mancante;
}
int N;
int main() {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
cin>>N;
int P[N];
for (int i=0;i<2*N-2;i++) P[i]=0;
for (int i=0;i<2*N-2;i++)
{ cin>>P[i];}
cout<<trova(N,P);
return 0;
}