编程题:24
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] parts = scanner.next().split("/");
int a = Integer.parseInt(parts[0]);
int b = Integer.parseInt(parts[1]);
int g = gcd(a, b);
System.out.printf("%d/%d", a / g, b / g);
}
public static int gcd(int x, int y) {
while (y != 0) {
int temp = y;
y = x % y;
x = temp;
}
return x;
}
}
浙公网安备 33010602011771号