牛客编程题(C语言):HJ9 提取不重复的整数

https://www.nowcoder.com/exam/oj/ta?tpId=37

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

提交代码

#include <stdio.h>
int main(void){
    int n,a,res=0;
    scanf("%d",&n);
    int list[10]={0};
    
    while(n>0){
        a = n%10;
        if(list[a]==0){
            list[a] =1;
            res *= 10;
            res += a;
        }
        n /= 10;
    } 
    printf("%d",res);
    return 0;
}

执行结果

posted @ 2022-05-15 21:55  孤舟浮岸  阅读(185)  评论(0)    收藏  举报