public class chuan {
public static void main(String[] args){
String s = "afgdefgh";
System.out.println(new chuan().arc( s));
}
public String arc(String s){
int x = s.length()/2;
String head = s.substring(0,x);
String tail = s.substring(x);
String temp = arc_sub(head);
return temp+tail;
}
public String arc_sub(String head){
char min_temp;
char exchange_temp;
char temp[] = head.toCharArray();
int index = 0;
for(int i =0;i<temp.length;i++){
index = i;
min_temp = temp[i];
int j=i+1;
for(;j<temp.length;j++){
if(temp[j]<min_temp){
index = j;
}
}
exchange_temp = temp[index];
temp[index] = temp[i];
temp[i] = exchange_temp;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载