Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num1 = sc.nextInt(); int num2 = sc.nextInt(); if (num1 < num2) { for (int i=1; i<=9; i++){ for (int j=num1; j<=num2; j++) System.out.printf("%d * %d = %2d ", j, i, j*i); System.out.println(); } } else { for (int i=1; i<=9; i++){ for (int j=num1; num2<=j; j--) System.out.printf("%d * %d = %2d ", j, i, j*i); System.out.println(); } } } } | cs |