import java.io.*;
public class Zo{
public static void main(String arg[]) throws IOException {
InputStreamReader str=new InputStreamReader(System.in);
BufferedReader str1=new BufferedReader(str);
String s=str1.readLine();
String ch= " ";
for(int i=s.length();i> =0;i--){
int j=0;
while( j <i){
if(s.charAt(i)==s.charAt(j))
break;
else j++;
}
System.out.println(s.charAt(i));
}
}
}
为什么我这样写不能输出啊!
------解决方案--------------------
import java.io.*;
public class Zo{
public static void main(String arg[]) throws IOException {
public static void main(String arg[]) throws IOException {
InputStreamReader str=new InputStreamReader(System.in);
BufferedReader str1=new BufferedReader(str);
String s=str1.readLine();
for (int i = 0; i < s.length(); i++) {
s = s.substring(0, i + 1) + s.substring(i + 1).replaceAll( " "+s.charAt(i), " ");
}
System.out.println(s);
}
}