有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何显示回文?

我想显示两个3位数的乘积的回文,范围从100到999。我的代码出了点问题,我无法定位

public static void main (String[] args) {
   int num = 0, remainder = 0, sum = 0, b;
   int temp;

   for (b = 999; b >= 100; b--) {
      for (a = 999; a >= 100; a--) {
         num = (a * b);
         temp = num;

         while (num > 0) { 
            remainder = num % 10;  
            sum = (sum * 10) + remainder;    
            num = num / 10;
         }

         if (temp == sum)   
            System.out.println(temp);           
      }
   }
}

我期待一个输出,但我没有得到任何输出


共 (0) 个答案