zoukankan      html  css  js  c++  java
  • Reverse Integer

    import java.util.*;
    public class Solution {
        public static int reverse(int x) {
        int a=x,tmp=0,i;
        int []b=new int[32];
        for(i=0;i<32;i++){
        if(a!=0){
        b[i]=a%10;
        a=a/10;
        }
        else
        break;
        }
        int in=1;
            for(int j=i-1;j>=0;j--){
            tmp+=b[j]*in;
            in*=10;
            }
        return tmp; 
    //     int res = 0;
    // while (x != 0) {
    // res = res * 10 + x % 10;
    // x = x / 10;
    // }
    // return res;


        }
        public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        while(cin.hasNextInt()){    
        int n=cin.nextInt();
        System.out.println(Solution.reverse(n));
        }
        }
    }


  • 相关阅读:
    第四次博客
    第三次作业
    第二次作业
    入学的第一次作业
    第四次作业
    第三次作业
    第二次随笔作业
    第一次随笔
    第四次作业
    第三次作业
  • 原文地址:https://www.cnblogs.com/gaoxiangde/p/4379896.html
Copyright © 2011-2022 走看看