Function call in C Language 08-the brute-force law is used to calculate the maximum and minimum public multiples of the four numbers, and the 08 common
// Array Enumeration
/*
========================================================== ============================
Question: calculate the maximum or least common number of four numbers.
========================================================== ============================
*/
# Include <stdio. h>
# Define N 4
Main ()
{
Int a [N], gys, gbs;
Int I, j, m = 1;
Int flag = 1;
Printf ("Enter % d integers:", N );
For (I = 0; I <N; I ++)
Scanf ("% d", & a [I]);
For (j = a [0]; j> = 1; j --)
If (a [0] % j = 0 & a [1] % j = 0 & a [2] % j = 0 & a [3] % j = 0)
{
Gys = j;
Break;
}
Printf ("maximum common divisor: % d \ n", gys );
While (flag)
{
If (m % a [0] = 0 & m % a [1] = 0 & m % a [2] = 0 & m % a [3] = 0)
{
Gbs = m;
Flag = 0;
}
Else m ++;
}
Printf ("minimum public multiple: % d \ n", gbs );
}
/*
========================================================== ============================
Rating: it is a brute-force method. It is obviously not a good algorithm, but for computers with fast computing speed,
This is a practical approach.
========================================================== ============================
*/
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.