Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Intermediate problems in plastic surgery
Intermediate problems in plastic surgery
int gy(int*,int,int *); The common divisor function returns all common divisors. I don't have a maximum value to insert, because it's too hard to get. You must add a maximum value to insert. (I took a screenshot of 100 and got 1 group of random numbers with common divisor.)

int gb(int*,int); Return the least common multiple, the acquisition time is too long, and I have the patience to run around with the program.

Because I am constantly circulating the convention of+1-1 seeking common multiples, the theory can be found, but it is very slow. If you are not satisfied, you can only see if other experts can give a better algorithm.

As the picture shows, I only ran the common denominator. If you don't want to run automatically in a loop, just comment out two goto statements.

# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# include & lttime.h & gt

# Definition? numsize? five

int? gy(int*,int,int? *);

int? gb(int*,int);

int? Master ()

{

int? a[numsize],I,*p,mgy[ 10],mgb=0,*gyp,size

p = a;

gyp = mgy

aa:? srand(time(NULL));

for(I = 0; I<5; i++)

a[I]=(int)rand();

Printf ("Generate random number: \ n");

for(I = 0; I & ltnumsizei++)

{

printf("%d\n ",a[I]);

}

size=gy(p,numsize,gyp);

If (size ==0)

{

Printf ("no common divisor \ n");

goto? aa;

}

other

{

Printf ("The greatest common divisor is:");

for(I = 0; I< size; i++)

printf("%d?" ,mgy[I]);

}

bb:? for(I = 0; I<5; i++)

a[I]=(int)rand();

Printf ("Generate random number: \ n");

for(I = 0; I & ltnumsizei++)

{

printf("%d\n ",a[I]);

}

mgb=gb(p,numsize);

If (mgb==0)

{

Printf ("no common multiple \ n");

goto? bb;

}

other

{

Printf ("the least common multiple is: %d\n", mgb);

}

}

int? gy(int? *p,int? size,int? *sp)

{

int? min=p[0],I,flog,count = 0;

for(I = 1; I< size; i++)

{

if(p[I]& lt; Minimum)

{

min = p[I];

}

}

while(min & gt; 1)

{

flog = 1;

for(I = 0; I< size; i++)

{

if(p[i]%min! =0)

{

flog = 0;

Break;

}

}

if(flog== 1)

{

* sp = min

sp++;

count++;

}

min-;

}

Return? Count;

}

int? gb(int? *p,int? Size)

{

int? max=p[0],I,flog,mgb = 0;

for(I = 1; I< size; i++)

{

if(p[I]& gt; Max)

{

max = p[I];

}

}

while( 1)

{

flog = 1;

for(I = 0; I< size; i++)

{

If (max? %? p[i]! =0)

{

flog = 0;

Break;

}

}

if(flog== 1)

{

mgb = max

Break;

}

max++;

}

Return? mgb

}