国产成人AV一区二区三区在线_国产成人精品无码免费看_国产成人无码无卡在线观看_国产精品成人A区在线观看_国产日韩精品欧美一区_国产亚洲精品自在久久蜜TV_久草热久草热线频97精品_久久久噜噜噜久久中文福利_久久婷婷五月综合色国产免费观看_日日狠狠久久偷偷色综合0,九一桃色在线观看,久久97精品久久久久久久不卡,国产成人精品亚洲精品

定義一個(gè)類并main()中new一個(gè)對(duì)象測(cè)試實(shí)現(xiàn)之,。

訪客2023-11-14 03:57:487

定義一個(gè)類并main()中new一個(gè)對(duì)象測(cè)試實(shí)現(xiàn)之,。

一個(gè)簡(jiǎn)單的學(xué)生成績(jī)管理,就包含你要的內(nèi)容,,供參考:

#include<iostream>#include<string>using namespace std;class Student{public:Student(string id="NULL",double score=0){};static double sum();static double average();string getid();double getscore();void setid(string s);void setscore(double s);void printfstudentinto();private:string id;double score;static double total_score;static double count;};string Student::getid(){return id;}double Student::getscore(){return score;}void Student::printfstudentinto(){cout<<"學(xué)生信息: ";cout<<"id: "<<getid()<<" score: "<<getscore()<<endl;}void Student::setid(string s){id=s;}void Student::setscore(double s){score=s;++count;total_score=total_score+score;}double Student::sum(){return total_score;}double Student::average(){double average=0.0;average=total_score/count;return average;}double Student::total_score=0.0;double Student::count=0.0;int main(){Student stu[10];int n;double s;string id;cout<<"請(qǐng)輸入學(xué)生的·人數(shù)(1~10):";cin>>n;for(int i=0; i<n; i++){cout<<"請(qǐng)輸入第 "<<i+1<<" 位學(xué)生的id,、score: ";cin>>id;cin>>s;stu[i].setid(id);stu[i].setscore(s);}for(int i=0; i<n; i++)stu[i].printfstudentinto( );cout<<"total_score:"<<Student::sum()<<endl;cout<<"average:"<<Student::average()<<endl;return 0;}

文章評(píng)論