/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication26;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author 86188
*/
public class question4 {
public static void main(String[] args)
{
ArrayList<String> list=new ArrayList<String>();
Scanner in=new Scanner(System.in);
System.out.println("请输入姓名名单,以空格分隔姓名,以end结束输入");
String str1;
while(true)
{
str1=in.next();
if(str1.compareTo("end")==0) break;
list.add(str1);
}
int i=list.size();
String temp;
for(int m=0;m<i;m++)
for(int n=1;n<i;n++)
{
if((list.get(m).compareTo(list.get(n)))>0)
{
temp=list.get(n);
list.set(n,list.get(m));
list.set(m,temp);
}
}
for(int j=0;j<i;j++)
System.out.print(list.get(j)+" ");
}
}
Java实现输入中文拼音的排列
最新推荐文章于 2022-03-23 11:22:08 发布