Cod sursa(job #549495)
| Utilizator | Data | 8 martie 2011 17:37:01 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
using namespace std;
#include <fstream>
ifstream fin("euclid2.in");
ofstream fout("euclid2.out");
void comp(unsigned int n,unsigned int a,unsigned int b);
int main()
{
unsigned int n,a,b;
fin>>n;
comp(n,a,b);
}
void comp(unsigned int n,unsigned int a,unsigned int b)
{
unsigned int i;
for(i=1;i<=n;i++)
{
fin>>a>>b;
while(a!=b)
{
if(a<b)
b=b-a;
if(a>b)
a=a-b;
}
fout<<a<<"\n";
}
}
