我搞不懂我的代碼錯(cuò)在哪里
import java.util.Arrays;
public class HelloWorld {
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? HelloWorld hello=new HelloWorld();
? ? ? ? int[] nums={89,-23,64,91,119,52,73};
? ? ? ? hello.rank(nums);
? ? ? ??
? ? ? ??
? ? }
? ??
? ? //定義方法完成成績(jī)排序并輸出前三名的功能
? ? public void rank(int[] scores){
? ? ? ? Arrays.sort(scores);
? ? ? ? System.out.println("qiansanming");
? ? ? ? count=0;
? ? ? ? for(int i=scores.length-1;i>=0;i--){
? ? ? ? ? ? if(scores[i]<0){
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ?if(scores[i]>100){
? ? ? ? ? ? ? ?continue;
? ? ? ? ? ?}
? ? ? ? ? ?count++;
? ? ? ? ? ?if(count<4){
? ? ? ? ? ?System.out.println(scores[i]);
? ? ? ? ? ?
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? }
? ? }
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
}
2015-12-03
count=0; 應(yīng)為 int count = 0;
需指定變量的類型。
2015-11-13
count沒定義,編譯失敗