import?java.util.Arrays;
public?class?HelloWorld?{
????
????//完成?main?方法
????public?static?void?main(String[]?args)?{
????????HelloWorld?hello?=?new?HelloWorld();
????????int?scores[]={89,-23,64,91,119,52,73};
????????hello.a(scores);???????
????}????
????//定義方法完成成績排序并輸出前三名的功能
????
????public?void?a(int?[]?scores){
????????Arrays.sort(scores);
????????for(int?i=scores.length-1;i>=scores.length-3;i--){
????????????//if?(i>=scores.length-2)
????????????System.out.print(scores[i]);
????????????System.out.println();
????????}?????
????}??
}
2016-08-31
并沒有判斷你的數(shù)是否在0--100之間?
2016-09-27
這個邏輯上應(yīng)該是沒有啥問題的 ?就是統(tǒng)計數(shù)組中最大的三個數(shù)
2016-09-01
恩 ?我知道的 ?我就是想問for循環(huán)這一塊的思想有問題嗎 ?我怕如果這一塊我的思想有錯誤會導(dǎo)致學(xué)到后面出錯
2016-08-31
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello = new HelloWorld();
? ? ? ? int[] scores={89,-23,64,91,119,52,73};
? ? ? ? System.out.println("考試成績的前三名為:");
? ? ? ? hello.sort(scores);
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void sort(int[] scores) {
? ? ? ? int count=0;
? ? ? ? Arrays.sort(scores);
? ? ? ? for(int i=scores.length-1;i>0;i--) {
? ? ? ? ? ? if(scores[i]>=0&&scores[i]<=100) {
? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? ? ? count++;
? ? ? ? ? ? }
? ? ? ? ? ? if(count==3)
? ? ? ? ? ? break;
? ? ? ? ? ??
? ? ? ? }
? ? }?
? ??
2016-08-31
沒有判斷成績合不合規(guī)。