#include <iostream>#include <iomanip>using namespace std;class Student{private: string strname; int nindex; double score;public: string getstrname() {return strname;} int getnindex() {return nindex;} double getscore() {return score;} void setstrname(string strnewname) {strname=strnewname;} void setnindex(int nnewindex) {nindex=nnewindex;} void setscore(double newscore) {score=newscore;}};int main(){Student stu1,stu2;stu1.setstrname("张三");stu1.setnindex(100);stu1.setscore(90);stu2.setstrname("李四");stu2.setnindex(101);stu2.setscore(70);cout<<"学生成绩"<<endl;cout<<left;cout<<setw(10)<<"学号"<<setw(10)<<"姓名"<<setw(10)<<"成绩"<<endl;cout<<setw(10)<<stu1.getnindex(100)<<setw(10)<<stu1.getstrname("张三")<<setw(10)<<stu1.getscore(90)<<endl;cout<<setw(10)<<stu2.getnindex(101)<<setw(10)<<stu2.getstrname("李四")<<setw(10)<<stu2.getscore(70)<<endl; return 0;}
- 1 回答
- 0 关注
- 1008 浏览
添加回答
举报
0/150
提交
取消