日期:2014-05-20 浏览次数:20740 次
public static void main(String[] args) {
System.out.println("请输入三个整形数字");
Scanner scan = new Scanner(System.in);
int[] a = new int[3];
a[0] = scan.nextInt();
a[1] = scan.nextInt();
a[2] = scan.nextInt();
Arrays.sort(a);
for(int temp:a){
System.out.println(temp);
}
scan.close();
}
import java.io.*;
public class InputTest {
public static void sort(double[] a)
{
for(int i=0;i<a.length-1;i++)
for(int j=i+1;j<a.length;j++)
{
if(a[i]<a[j])
{
double temp;
temp=a[i];a[i]=a[j];a[j]=temp;
}
}
}
public static void main(String[] args)
{
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
double[] array=new double[3];
try{
for(int i=0;i<array.length;i++)
{
System.out.println("请输入第"+(i+1)+"个数");
array[i]=Double.parseDouble(stdin.readLine());
}
}catch(Exception e){}
sort(array);
System.out.print("排序后的结果为:");
for(int i=0;i<array.length;i++)
System.out.print(array[i]+" ");
}
}