1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 System.out.print("Enter a number: "); 9 int number = input.nextInt(); 10 11 input.close(); 12 13 reverse(number); 14 } 15 16 public static void reverse(int number) 17 { 18 if(number < 10) 19 System.out.print(number); 20 else 21 { 22 System.out.print(number % 10); 23 reverse(number / 10); 24 } 25 } 26 }
时间: 2024-12-25 03:10:45