public class text2 {
public static void main(String[] argv){
//String s="123";
int i=123;
aa(i);
}
public static void aa(int s){


}
}
写一个int型的逆排序。例如:123,输出是:321.请问高手怎么写?

解决方案 »

  1.   

    public   static   void   aa(int   s){
            StringBuilder sb = new StringBuilder(String.valueOf(s));
            sb.reverse();
            System.out.println(sb.toString());
    }
      

  2.   

    int i = 123;
    String s = String.valueOf(i);
    StringBuilder sb = new StringBuilder(s);
    System.out.println(sb.reverse());
      

  3.   

    package com.awt;public class Testt {
    public static String StringTest(String s){   
      char[] t = new char[s.length()];  
      for(int i=0;i<s.length();i++){
       int j = s.length()-1-i;
      t[j] = s.charAt(i);
      }   
      String s1 = new String(t);
      System.out.println(s1);
      return s1;   
    }
    public static void main(String[] args) {
      String s = "123";
      StringTest(s);
    }
    }
      

  4.   

    public   static   void   aa(int   s){ 
       int a = s/100;
       int b = s/10-a*10;
       int c = s-(a*100+b*10);
       int sum = c*100+b*10+a;
       System.out.println(sum);
      

  5.   

    先转成字符串,然后调用REVERSE()..