Pagini recente » Cod sursa (job #1507968) | Cod sursa (job #2284448) | Cod sursa (job #1179740) | Cod sursa (job #2147645) | Cod sursa (job #2474945)
import java.io.*;
import java.util.Scanner;
class Main {
public static void main(String args[]) {
File inFile = new File("euclid2.in");
try {
Writer outFile = new FileWriter("euclid2.out");
Scanner scanner = new Scanner(inFile);
Integer T = scanner.nextInt();
int a = 0;
int b = 0;
for(int i=0; i<T; i++){
a = scanner.nextInt();
b = scanner.nextInt();
outFile.write(get_gcd(a,b).toString());
outFile.write('\n');
}
scanner.close();
outFile.close();
} catch (Exception e) {
// e.printStackTrace();
}
}
private static Integer get_gcd(Integer a, Integer b){
if(b == 0){
return a;
}
return get_gcd(b, a % b);
}
}