問題及**:
/*
*檔名稱:project.cpp
*作 者:陳文青
*完成日期:2023年6月16日
*版 本 號:v1.0
**問題描述:
(1)定義學生類,其中包含姓名、c++課、高數和英語成績及總分資料成員。
(2)用物件陣列進行儲存學生的成績,讀入成績並計算總分;將總分高於平均總分且沒掛科的同學的資訊儲存到檔案pass_score.dat中。
*程式輸入:
*程式輸出:
*/#include #include#includeusing namespace std;
//定義學生類
class student
; double get_total()
static int get_stu_num() //stu_num為私有資料成員,而在後續程式中需要呼叫,所以,設定函式用於提取靜態變數
static double get_total_sum()
bool pass(); //用於測試學生成績是否及格
friend istream& operator>>(istream &in, student &s); //過載輸入流
friend ostream& operator<<(ostream &out, student &s); //過載輸出流
private:
string name;
double cpp;
double math;
double english;
double total;
static int stu_num; //學生人數,處理為類的靜態成員合適
static double total_sum; //學生總分和
};int student::stu_num = 0; //將靜態成員賦值
double student::total_sum = 0;
bool student::pass() //用於測試學生成績是否及格
istream& operator>>(istream &in, student &s) //過載輸入流
ostream &operator<<(ostream &out, student &s) //過載輸出流
infile.close();
//總分高於平均總分且沒掛科的同學的資訊儲存到檔案pass_score.dat中
//求總分平均並輸出
if(student::get_stu_num()>0)
讀入資料到檔案尾
while(!infile.eof())
關閉檔案
infile.close();
第十四周專案三
問題及 all right reserved.檔名稱 是否二叉排序樹.cpp 版本號 v1.0 問題描述 設計乙個演算法,判斷給定的二叉樹是否是二叉排序樹。輸入描述 用二叉樹的形式輸入數字 程式輸出 判斷結果 include include define maxsize 100 typedef in...
第十四周 專案1(2)
問題描述及 ifndef btree h included define btree h included 煙台大學計控學院 作 者 王力源 完成日期 2016年12月8日 問題描述 請用 共n 25據,每塊資料個數s 5作為資料表,自行構造索引表,分別對查詢85測試。endif btree h i...
第十四周專案二
檔名稱 jcy 作 者 賈存鈺 完成日期 2017年12月7日 問題描述 已知乙個關鍵字序列為if while for case do break else struct union int double float char long bool,共15個字串,雜湊函式h key 為關鍵字的第乙個字...