#include#includeusingnamespacestd;classStudent{private:stringsNO;//學(xué)號intcre..."/>

女人久久久www免费人成看片,国内自拍偷拍网,国产一区二区三区免费在线观看,欧美精品三区四区,91久久国产综合久久91,欧美成人精品第一区二区三区 ,美女成人在线观看

軟題庫 移動APP 掃碼下載APP 隨時隨地移動學(xué)習(xí) 培訓(xùn)課程
試卷名稱 2010年下半年程序員考試下午真題試題(案例分析)
考試中心《2010年下半年程序員考試下午真題試題(案例分析)》在線考試
試卷年份2010年下半年
試題題型【分析簡答題】
試題內(nèi)容

閱讀以下說明和C++代碼,將應(yīng)填入 (n) 處的語句或語句成分寫在答題紙的對應(yīng)欄內(nèi)。
【說明】
某數(shù)據(jù)文件students.txt的內(nèi)容為100名學(xué)生的學(xué)號和成績,下面的程序?qū)⑽募械臄?shù)據(jù)全部讀入對象數(shù)組,按分數(shù)從高到低進行排序后選出排名前30%的學(xué)生。
【C++代碼】
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
class Student {
   private:
    string sNO;   //學(xué)號
    int credit;    //分數(shù)
   public:
    Student(string a,int b) { sNO = a; credit = b;}
    Student( ){ }
    int getCredit( );
    void out( );
};
  (1)  ::getCredit( ) {
   return credit;
}
  (2)  ::out( ) {
   cout << "SNO: " << sNO << ", Credit=" << credit << end1;
}
class SortStudent {
   public:
    void sort(Student *s, int n);
    SortStudent(){}
};
void SortStudent::sort(Student *s,int n) {
   for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
if(s[i].  (3)  < s[j].  (4)  ) {
  Student temp = s[i];    s[i] = s[j];    s[j] = temp;
}
    }
   }
}
int main(int argc, char* argv[ ])
{
   const int number = 100;   //學(xué)生總數(shù)
   ifstream students;
   students.open("students.txt");
   if(!students.is_open()) {
    throw 0;
   }
  
   Student *testStudent =   (5)  [number];
   int k = 0;
   string s;
   while (getline(students,s,’\n’)) {    //每次讀取一個學(xué)生的學(xué)號和成績
    Student student(s.substr(0,s.find(’,’)), atoi(s.substr(s.find
    (’,’)+1).c_str()));
    testStudent[k++] = student;
   }
   students.close();
  
     (6)  ;
   ss.sort(testStudent,k);
   cout <<"top 30%: "<<end1;
   for(k = 0; k < number * 0.3; k++) {
    testStudent[k].out();
   }
   delete [ ]testStudent;
   return 0;
}


相關(guān)試題

推薦文章
合作網(wǎng)站內(nèi)容