HJ009
import java.util.Scanner;
import java.lang.Math;
import java.util.Arrays;
public class HJ009
{
public static void main(String[] args)
{
int aim,digit,pot;
int[] rs={-1,-1,-1,-1,-1,-1,-1,-1,-1};
Scanner sc;
sc=new Scanner(System.in);
aim=sc.nextInt();
digit=0;
pot=0;
for(int k=1;k<=9;k++)
{
digit=calcNum(aim,k);
//System.out.printf("digit is %d%n",digit);
if(digit==0)
break;
else
{
pot=saveArray(digit,pot,rs);
//System.out.printf("pot is %d%n",pot);
//System.out.printf("rs is %s%n",Arrays.toString(rs));
//System.out.printf("-------------%n");
}
}
printArray(rs,pot);
}
//Function:calculate current digit
private static int calcNum(int aim,int n)
{
return (aim % (int)Math.pow(10,n)) / (int)Math.pow(10,n-1);
}
//Function:save current digit into array
private static int saveArray(int digit,int pot,int[] rs)
{
int insert=1;
for(int i=1;i<=pot;i++)
{
if(rs[i-1]==digit)
{
insert=0;
break;
//cannot reach
//return pot;
}
else
;
}
if(insert==1)
{
rs[pot]=digit;
pot=pot+1;
}
else
;
return pot;
}
//Function:print rs array
private static void printArray(int[] rs,int pot)
{
for(int j=1;j<=pot;j++)
{
System.out.printf("%d",rs[j-1]);
}
}
}
HJ009RW
import java.util.Scanner;
class HJ009RW
{
public static void main(String[] args)
{ int aim,n,dgt,sum;
int[] jud,rs;
Scanner sc=new Scanner(System.in);
aim=sc.nextInt();
n=1;
sum=0;
jud=new int[10];
rs=new int[10];
for(int i=1;i<=jud.length;i++) jud[i-1]=-1;
for(int j=1;j<=rs.length;j++) rs[j-1]=-1;
while(true)
{ dgt=aim%10;
if(jud[dgt]==-1)
{ jud[dgt]=0;
rs[n-1]=dgt;
n=n+1;
}
aim=aim/10;
if(aim==0) break;
}
for(int k=1;k<=rs.length;k++)
{ if(rs[k-1]!=-1) sum=sum*10+rs[k-1];
else break;
}
System.out.printf("%d%n",sum);
}
}