Cod sursa(job #574441)
Utilizator | Data | 7 aprilie 2011 10:45:34 | |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
int cmmdc(int a,int b)
{
int r;
if(!b) return a;
while(b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
ifstream f ("euclid2.in");
ofstream g ("euclid2.out");
int a,b,t;
f>>t;
for(int i=1;i<=t;i++)
{
f>>a>>b;
g<<cmmdc(a,b)<<endl;
}
f.close();
g.close();
return 0;
}