字符组接收字符串:
char[] str=m.toCharArray();
冒泡排序:
for(int i=0;i
for(int j=i+1; j
{
if(str[i]>str[j]){
char c=str[i];
str[i]=str[j];
str[j]=c;
}
}
输出注意:
for(int i=0;i
{
if(i==str.length-1)
System.out.println(str[i]);
else
System.out.print(str[i]+" ");
}
代码:
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner cin= new Scanner(System.in);
String m;
while(cin.hasNext()){
m=cin.nextLine();
char[] str=m.toCharArray();
for(int i=0;i
for(int j=i+1; j
{
if(str[i]>str[j]){
char c=str[i];
str[i]=str[j];
str[j]=c;
}
}
}
for(int i=0;i
{
if(i==str.length-1)
System.out.println(str[i]);
else
System.out.print(str[i]+" ");
}
;
}
}
}