Răspuns :
Salut! Ai mai jos subprogramul. E 100% testat si functioneaza perfect! Bafta!
void reorder( int * v, int n ){
int p1, p2;
p1 = 0;
p2 = n - 1;
while ( p1 <= p2 ) {
int d = 2;
while ( d * d <= v[p1] && v[p1] % d != 0 )
d ++;
if ( d * d > v[p1] && v[p1] >= 2 )
p1 ++;
else {
int aux = v[p2];
v[p2] = v[p1];
v[p1] = aux;
p2 --;
}
}
}
void reorder( int * v, int n ){
int p1, p2;
p1 = 0;
p2 = n - 1;
while ( p1 <= p2 ) {
int d = 2;
while ( d * d <= v[p1] && v[p1] % d != 0 )
d ++;
if ( d * d > v[p1] && v[p1] >= 2 )
p1 ++;
else {
int aux = v[p2];
v[p2] = v[p1];
v[p1] = aux;
p2 --;
}
}
}
void modificare(int v[], int n)
{
int i, j, k1 = 0, k2 = 0, x, v1[10005], v2[10005];
bool prim;
for(j = 0; j < n; j ++)
{
x = v[j];
prim = true;
for (i = 2; i * i <= x; i ++)
if(x % i == 0)
{
prim = false;
break;
}
if(prim) v1[k1 ++] = x;
else v2[k2 ++] = x;
}
for(j = 0; j < k1; j ++)
v[j] = v1[j];
for(j = k1; j < n; j ++)
v[j] = v2[j - k1];
return;
}
{
int i, j, k1 = 0, k2 = 0, x, v1[10005], v2[10005];
bool prim;
for(j = 0; j < n; j ++)
{
x = v[j];
prim = true;
for (i = 2; i * i <= x; i ++)
if(x % i == 0)
{
prim = false;
break;
}
if(prim) v1[k1 ++] = x;
else v2[k2 ++] = x;
}
for(j = 0; j < k1; j ++)
v[j] = v1[j];
for(j = k1; j < n; j ++)
v[j] = v2[j - k1];
return;
}
Vă mulțumim pentru vizita pe site-ul nostru dedicat Informatică. Ne dorim ca informațiile furnizate să vă fi fost utile. Dacă aveți întrebări sau aveți nevoie de suport suplimentar, nu ezitați să ne contactați. Revenirea dumneavoastră ne bucură, iar pentru acces rapid, adăugați-ne la favorite!