题目描述
代码实现
package TEST;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int max = sc.nextInt();int min = sc.nextInt();int sum = 0, temp;while (max != 0 && min != 0) {if (max < min) {temp = max;max = min;min = temp;}sum += max / min;temp = max;//为了保存此时的max值max = min;min = temp % min;}System.out.println(sum);}
}
答案
21