(Java program問題) 請救我(3)

2008-03-10 8:04 am
write the following method to display three numbers in increasing order:
public static void sort(double num 1, double num 2, double num 3)

回答 (1)

2008-03-10 7:30 pm
✔ 最佳答案
public static void sort(double num1, double num2, double num3)
{
double d1,d2; // where d1 < = d2
double e1,e2,e3; // where e1 < = e2 < = e3
if(num1 < = num2){d1=num1;d2=num2;}
else{d1=num2;d2=num1;}
if(num3 < = d1){e1=num3;e2=d1;e3=d2;}
else{e1=d1;
if(num3 < = d2){e2=num3; e3=d2;}
else{e2=d2;e3=num3;}
}
System.out.println(""+e1);
System.out.println(""+e2);
System.out.println(""+e3);
}

2008-03-10 11:32:27 補充:
Sorry, Yahoo reformats the program as if it was an HTML page, so it is not very readable.
If you prefer me to send you a text file, PM me with your e-mail.


收錄日期: 2021-04-13 15:16:08
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080310000051KK00009

檢視 Wayback Machine 備份