简单for循环进行数组排序

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Arrays;
public class Triangle{
public static void main(String[] args)throws IOException
{
String m=new String("");
int[] a={0,0,0};
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter three numbers:");
m=stdin.readLine();
Scanner scan=new Scanner(m);
for(int i=0;i<3;i++)
{
a[i]=scan.nextInt();
}
Arrays.sort(a);
System.out.println("sorted:");
for(int i=0;i<3;i++)
System.out.print(a[i]+" ");//升序排列
}
}

posted @ 2015-05-21 21:55  sunshinewxz  阅读(2116)  评论(0编辑  收藏  举报