编程题: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;
}

}

posted on 2025-05-12 23:24  Swishy  阅读(5)  评论(0)    收藏  举报