JAVA

Monday, December 26, 2005

Lab12/19

import java.io.*;

public class Sorting {
public Sorting() {
}

public static void main(String[] args) throws IOException {
double[] score = new double[5];
int i, a, b,m;
double y;
BufferedReader keyboard = new BufferedReader(new InputStreamReader(
System.in));
System.out.println("Enter 5 numbers :");
for (i=0; i<5; i++) {
score[i] = Double.parseDouble(keyboard.readLine());
}
for (a = 0; a < 5;a++)
{ m=a+1;
for(b=m;b<5;b++){

if (score[a] > score[b]) {
y = score[a];
score[a] = score[b];
score[b] = y;
}
}
}
for (i=0;i< 5;i++) {
System.out.println(score[i]);
}
}
}















http://home.pchome.com.tw/club/savvygirl/me.JPG

0 Comments:

Post a Comment

<< Home