Cod sursa(job #799428)
| Utilizator | Data | 18 octombrie 2012 22:52:29 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include<fstream>
using namespace std;
int cmmdc(int x, int y){
if(x == 0) return y;
else if(y == 0) return x;
else return cmmdc(y, x%y);
}
int main(){
ifstream fin("cmmmdc.in");
ofstream fout("cmmmdc.out");
int x, y, cm, aux;
fin >> x >> y;
if(x < y){
aux = x;
x = y;
y = aux;
}
cm = cmmdc(x, y);
fout << cm;
fin.close();
fout.close();
return 0;
}
