大神指點一下
package com.lianxi;
import java.util.Arrays;
public class Biancheng {
public static void main(String[] args) {
Biancheng hello=new Biancheng();
int[] nums=hello.print(7);
Arrays.sort(nums);
System.out.println("考試成績的前三名為:");
System.out.println(Arrays.toString(nums));
System.out.println(nums[6]);
System.out.println(nums[5]);
System.out.println(nums[4]);
}
? ? ?public ?int[] ?print(int length) {?
? ? int[] scores={89,-23,64,91,119,52,73};
? ? int[] nums=new int[length];
? ? ?
? ? for(int i=0;i<scores.length;i++){?
? ? if(0<scores[i]&&scores[i]<100){
? ? int j=0;
nums[j]=scores[i];
j++;
? ? }
? ? }
? ? return nums;
? ? ?}
? ? ?
? ??
}
哪里不對了?
2017-06-05
你寫的亂了,建議你研究一下這個
2017-06-04
import java.util.Arrays;
public class Biancheng {
public static void main(String[] args) {
Biancheng hello=new Biancheng();
int[] nums=hello.print(7);
Arrays.sort(nums);
System.out.println("考試成績的前三名為:");
// System.out.println(Arrays.toString(nums));
System.out.println(nums[6]);
System.out.println(nums[5]);
System.out.println(nums[4]);
}
? ? ?public ?int[] ?print(int length) {?
? ? int[] scores={89,-23,64,91,119,52,73};
? ? int[] nums=new int[length];?
? ? for(int i=0;i<scores.length;i++){?
? ? if(scores[i]<0||scores[i]>100){
? ? continue;
? ? }
nums[i]=scores[i];
? ?
? ? ? ? } return nums;
? ?
? ? ?}
? ? ?
? ??
}
調(diào)好了,不一定非得用給定的答案!
2017-06-04
代碼有些混亂,有些代碼邏輯不夠明確。寫代碼時先要縷清思路。給你個代碼參考下