Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int cmmdc(int a, int b)
- {
- int t;
- while (b != 0)
- {
- t = b;
- b = a % b;
- a = t;
- }
- return a;
- }
- int a[101];
- int main()
- {
- int n;
- ifstream fin("cmmdc.in");
- fin>>n;
- for(int i=1; i<=n; i++)
- fin>>a[i];
- int d=cmmdc(a[1],a[2]);
- for(int i=3; i<=n; i++)
- d=cmmdc(d,a[i]);
- ofstream fout("cmmdc.out");
- fout<<d;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement