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

国产精品久久久久久免费免熟,五月婷婷激情综合网,欧美三级视频网站,一级少妇淫片,国产精品女教师av久久,啪啪免费视频,wwww黄色片

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

閱讀以下說(shuō)明和C++代碼,將應(yīng)填入 (n) 處的語(yǔ)句或語(yǔ)句成分寫在答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
某數(shù)據(jù)文件students.txt的內(nèi)容為100名學(xué)生的學(xué)號(hào)和成績(jī),下面的程序?qū)⑽募械臄?shù)據(jù)全部讀入對(duì)象數(shù)組,按分?jǐn)?shù)從高到低進(jìn)行排序后選出排名前30%的學(xué)生。
【C++代碼】
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
class Student {
   private:
    string sNO;   //學(xué)號(hào)
    int credit;    //分?jǐn)?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’)) {    //每次讀取一個(gè)學(xué)生的學(xué)號(hào)和成績(jī)
    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)試題

推薦文章