Write a program that asks the user to enter two integers, then calculates and displays their greatest common divisor (GCD).
Hint: The classic algorithm for computing the GCD, known as Euclid's algorithm, goes as follow: let m and n be variables containing the two numbers. If n is 0, then stop: m contains the GCD. Otherwise, compute the remainder when m is divided by n. Copy n into m and copy the remainder into n. Then repeat the process, starting with testing whether n is 0.
Example input:
12 28
Example output:
4
內容已隱藏#include * * * *** * *int main(){** * * * * ***** * ** * * n1, n2, i, gcd; *** * * * ** * ** ** * **** *** ** %d", &n1, * ** * *** * ** * * * * * * * * * * * * *** * * * i <= n1 **** * **** * i <= n2; ++i)