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

提取不重复的整数

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

import  java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        if(num%10==0){
            return;
        }
        LinkedHashSet<Integer> lhs=new LinkedHashSet<Integer>();
        while(num/10!=0){            
             lhs.add(num%10);
             num=num/10;
             if(num<10){
                lhs.add(num);
             }
        }
        Iterator it=lhs.iterator();
        while(it.hasNext()){
            System.out.print(it.next());
        }

    }
}
全部评论
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); LinkedHashSet set = new LinkedHashSet(); while(num > 10){ set.add(num%10); num /= 10; } set.add(num); Iterator it = set.iterator(); while(it.hasNext()){ System.out.print(it.next()); } } }
点赞 回复 分享
发布于 2022-08-20 16:58 湖南
你这个对于10以下的数没有处理
点赞 回复 分享
发布于 2022-03-29 18:02

相关推荐

CARLJOSEPH...:宝宝你戾气太大了
点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
今天 12:17
已编辑
商丘师范学院 Java
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
8
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务