深夜成人在线,chinese国产一区二区,欧美精品乱码,日韩欧美在线视频免费观看,国产午夜不卡,日韩av影院在线,五月天婷婷国产精品

軟題庫 移動APP 掃碼下載APP 隨時隨地移動學習 培訓課程
當前位置:信管網 >> 在線考試中心 >> 信息系統項目管理師題庫 >> 試題查看
試卷名稱 2010年下半年程序員考試下午真題試題(案例分析)
考試中心《2010年下半年程序員考試下午真題試題(案例分析)》在線考試
試卷年份2010年下半年
試題題型【分析簡答題】
試題內容

閱讀以下說明和Java代碼,將應填入 (n) 處的語句或語句成分寫在答題紙的對應欄內。
【說明】
某數據文件students.txt的內容為100名學生的學號和成績,下面的程序將文件中的數據全部讀入對象數組,按分數從高到低進行排序后選出排名前30%的學生。
【Java代碼】
import java.io.*;
 
class Student {
   private String sNO;       //學號
   private int Credit;  //分數
   public int getCredit( ){
    return Credit;
   }
   public String toString() {
    return "sNO = " + this.sNO + ", Credit = " + this.Credit;
   }
 
   Student(String sNO, int Credit){
      (1)   = sNO;
      (2)   = Credit;
   }
}
 
public class SortStudent {   
    void sort(Student[ ] s) { //Sort the array s[ ] in descending order of
    Credit
    for (int i = 0; i < s.length-1; i++) {
           for (int .j = i+1; j < s.length; j++) {
  if (s[i].  (3)  < s[j].  (4)  ) {
   Student tmp = s[i];
   s[i] = s[j];
   s[j] = tmp;
  }
}
    }
    }
 
  
    public static void main(String argv[ ]) {
    Student[ ] testStudent = new Student[size];
    try {

BufferedReader in = new BufferedReader(new FileReader
("students.txt"));
boolean done = false;
 
int i = 0;
while (!done) {
  String s = in.readLine();   //每次讀取一個學生的學號和成績
  if (s != null) {
   String tmp[ ] = s.split(",");
   testStudent[i++] =   (5)  (tmp[0], Integer.parseInt
   (tmp[1]));
  } else
   done = true;
}
in.close();
  (6)   = new SortStudent();
ss.sort(testStudent);
System.out.println("top 30%:");
for (int j = 0; j < size * 0.3; j++)
  System.out.println(testStudent[j]);
    } catch (IOException e) {
System.out.println("io error!");
    }catch (NumberFormatException e) {
System.out.println("not a number!");
    }
    }
 
     (7)   int size = 100; //學生總數
}


相關試題

推薦文章
合作網站內容