题解 | #提取不重复的整数#

提取不重复的整数

http://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1

import java.io.*;

public class Main{

public static void main(String [] args) throws Exception{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    int num = Integer.parseInt(bf.readLine());
    int [] arr = new int[10];
    StringBuilder sb = new StringBuilder();
    int divisor=10;
    int temp ;
    while (num>0){
        temp = num % 10;
         num /=divisor;
        if(arr[temp] == 1){
            continue;
        }
        arr[temp] = 1;
        sb.append(temp);
    }
    System.out.println(sb);
    
}

}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务