2012年4月12日 星期四

Java 數字翻轉


import java.util.Scanner;

public class NumberTurn{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String str;
  
                while( sc.hasNext() ){
                        str = sc.nextLine();
   
                        char c [] = str.toCharArray();
                        String tmp = "";
   
                        for( int i = c.length - 1; i >= 0; i-- ){
                                tmp += c[i];
                        }
   
                        System.out.println( Integer.parseInt(tmp) );
                }
        }
}

題目
參考程式

1 則留言:

  1. I’m seriously happy to discover this great site the future of this blog is getting good and more useful for me thanks and god bless you.
    IT Company India

    回覆刪除