The code is implemented as follows:
# Include <iostream>
Using namespace STD;
Int getg (int m, int N)
{
If (M <n)
{
M ^ = N;
N ^ = m;
M ^ = N;
}
If (n = 0)
Return m;
Return getg (n, m % N );
}
Int getng (int * arr, int N)
{
// Int IMAX = arr [0];
// For (INT I = 1; I <n; I ++)
// IMAX = getzuidagongyue (IMAX, arr [I]);
// Return IMAX;
If (n = 1)
Return * arr;
Return getg (ARR [n-1], getng (ARR, n-1 ));
}
/* Int getg (int * arr, int Len)
{
Int IMAX = arr [0], icurr, iremainder;
For (INT I = 1; I <Len; I ++)
{
Icurr = arr [I];
If (IMAX <icurr)
{
IMAX ^ = icurr;
Icurr ^ = IMAX;
IMAX ^ = icurr;
}
Iremainder = IMAX % icurr;
While (iremainder)
{
IMAX = icurr;
Icurr = iremainder;
Iremainder = IMAX % icurr;
}
IMAX = icurr;
} //
Return IMAX;
}
*/
Int getlcm (int m, int N)
{
Return M * n/getg (m, n );
}
Int getnlcm (int * arr, int Len)
{
If (LEN = 1)
Return * arr;
Return getlcm (ARR [len-1], getnlcm (ARR, len-1 ));
}
Int main ()
{
Cout <"----------------- g -------------------" <Endl;
Cout <"5767 and 4453:" <getg (5767,4453) <Endl;
Int arr [6] = {, 40 };
Cout <", 40, 30 and 80:" <getng (ARR, 6) <Endl;
Cout <"----------------- LCM -------------------" <Endl;
Cout <", 40, 30 and 80:" <getnlcm (ARR, 6) <Endl;
Getchar ();
Return 0;
}
I'm dizzy. csdn does not allow text containing g * C * D!