Cod sursa(job #1546919)
Utilizator | Bigfoot din padure megabytes112 | Data | 8 decembrie 2015 20:43:49 |
---|---|---|---|
Problema | Algoritmul lui Euclid | Scor | 0 |
Compilator | java | Status | done |
Runda | Arhiva educationala | Marime | 0.68 kb |
import java.io.*;
import java.util.*;
public class Main {
public static int cmmdc(int x, int y)
{
if (y > 0)
return cmmdc(y, x%y);
else
return x;
}
public static void main(String[] args) throws IOException{
Scanner fin = new Scanner(new FileInputStream("cmmdc.in"));
PrintStream fout = new PrintStream("cmmdc.out");
int x, y, n, i, z;
n = fin.nextInt();
for (i = 1; i <= n; i++)
{
x = fin.nextInt();
y = fin.nextInt();
z = cmmdc(x, y);
fout.println(z);
}
}
}