import java.io.*;
import java.util.*;
public class aaa{
public String shu(String str,int size){
String result="";
String min="";
String str1=str;
List vec = new ArrayList();
List vec1 = new ArrayList();
for(int j=0;result.length()!=str1.length()-size;j++){
for( int i = 0; i <str.length(); i++ ) {
vec.add(str.charAt(i));
if(i<size+1){
vec1.add(str.charAt(i));
}
}
result=result+Collections.min(vec1).toString();
str=str.substring(str.indexOf(Collections.min(vec1).toString())+1);
vec.clear();
vec1.clear();
}
return result;
}
public static void main( String[] args ) throws IOException {
BufferedReader bfr = new BufferedReader( new InputStreamReader( System.in ));
System.out.println( "请输入一个整数" );
String str = bfr.readLine();
System.out.println( "请输入你要删除的位数" );
int size = Integer.parseInt( bfr.readLine());
while( size >= str.length() ) {
System.out.println( "删除的位数必数小于数的长度,请重新输入" );
size = Integer.parseInt( bfr.readLine());
}
aaa a=new aaa();
/*String str="123456";
int size=2;*/
String aa=a.shu(str,size);
System.out.println(aa);
}
}
你看看 这个