Cod sursa(job #1447530)
| Utilizator | Data | 4 iunie 2015 17:47:27 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <algorithm>
#include <stdio.h>
using namespace std ;
int c ;
int divi(int a,int b) {
while (b) {
c=a%b ;
a=b ;
b=c ;
}
c=a ;
return c ;
}
int main() {
freopen ("euclid2.in" , "r" , stdin ) ;
freopen ("euclid2.out" , "w" , stdout ) ;
int n , x , y ;
scanf ("%d" , &n ) ;
for (int i=1 ; i<=n ; ++i) {
scanf ("%d%d" , &x , &y) ;
printf ("%d\n" , divi(x,y) ) ;
}
return 0 ;
}
