Cod sursa(job #2259636)
Utilizator | Data | 13 octombrie 2018 16:17:55 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
using namespace std;
int main()
{
int x, y;
cin >> x >> y;
while (x>0 && y>0)
{
if (x>y)
{
x=x-y;
}
else
{
y=y-x;
}
}
if (x<=0)
cout << y;
else
cout << x;
return 0;
}