This algorithm finds the greatest common divisor of
the nonnegative integers a and b, where not
both a and b are zero.
Input: a and
b (nonnegative integers, not both zero)
Output: Greatest common divisor
of a and b
| int gcd(int a, int b)
{ // make a largest if a < b then swap(a, b) while b <> 0 do begin r:= a mod b a:= b b:= r end return (a) } |
It is a set of pseudo codes on
the left. That is, your computer won’t understand it.
Please translate it into C++. Write a main function to read a data file, call this gcd function and
print results on a output file.
|
The following is your data file:
60
90
110
273
220
1400
315
825
20
40
331
993
2091
4807
2475
32670
67942
4209
490256
337