#include  
							 閱讀以下說(shuō)明和C++代碼,將應(yīng)填入 (n) 處的語(yǔ)句或語(yǔ)句成分寫在答題紙的對(duì)應(yīng)欄內(nèi)。成人学院中文字幕,国产午夜麻豆影院在线观看,久久男人免费视频,久久精品美女视频,www.福利视频,蜜桃一本色道久久综合亚洲精品冫,欧美三级视频
   
【說(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)試題
					   更多試題
 
                     10年專注信管,信管教育專注者,信管網(wǎng)優(yōu)勢(shì)
 10年專注信管,信管教育專注者,信管網(wǎng)優(yōu)勢(shì)
                       免費(fèi)試聽(tīng)信管網(wǎng)信息系統(tǒng)項(xiàng)目管理師課程
 免費(fèi)試聽(tīng)信管網(wǎng)信息系統(tǒng)項(xiàng)目管理師課程
                        全國(guó)前50名高分學(xué)員訪談:董麗(174)、李思...
 全國(guó)前50名高分學(xué)員訪談:董麗(174)、李思...
                       信息系統(tǒng)項(xiàng)目管理師高端班培訓(xùn)課程
 信息系統(tǒng)項(xiàng)目管理師高端班培訓(xùn)課程
					   信管老師100小時(shí)直播課程
 信管老師100小時(shí)直播課程
					  
					   軟考報(bào)名專題(報(bào)名時(shí)間、入口等)
 軟考報(bào)名專題(報(bào)名時(shí)間、入口等)
					   中級(jí)系統(tǒng)集成項(xiàng)目管理工程師通關(guān)課程
 中級(jí)系統(tǒng)集成項(xiàng)目管理工程師通關(guān)課程
					  
					   系統(tǒng)規(guī)劃與管理師課程(考試介紹與題型分析)
 系統(tǒng)規(guī)劃與管理師課程(考試介紹與題型分析)
					   軟題庫(kù):軟考在線題庫(kù)、支持手機(jī)答題
 軟題庫(kù):軟考在線題庫(kù)、支持手機(jī)答題