Stack
template
template
template
void Stack
template
template
int main() { Stack
Part1 9运行结果与分析:
运行结果:
运行结果分析:
在栈中放入5个数:5,10,2,22,7.输出栈顶元素7 输出结果正确。
Part1 9设计过程、思路与分析:
1. 先定义类模板template
=====================================================================
Part1 10: 文件读写:定义学生类数组,有N个人(N=5),包括姓名和语数外三
名课的成绩,通过重载<<和>>运算符实现学生数组的文件读写。(姓名用string name;)
#include
using namespace std; class student;
ostream& operator<<(ostream & os, student s); istream & operator >> (istream & is, student &s);
class student {
public: student() {} student(string name, int c_socre, int m_score, int e_score) { this->name = name; this->c_score= c_score; this->m_score = m_score; this->e_score = e_score; } friend ostream& operator<<(ostream & os, student s) { os << s.name << \s.e_score<
private: };
int main() { }
return is; }
string name; int c_score; int m_score; int e_score;
int i;
student s[N]; for( i=0;i
ofstream ofs(\if(!ofs) {
cerr<<\ exit(1); }
for( i=0;i ofs.write(reinterpret_cast ifstream ifs(\if(!ifs) { cerr<<\ exit(1); } for( i=0;i ifs.read (reinterpret_cast for(i=0;i Part1 10运行结果与分析: 运行结果: Part1 10设计过程、思路与分析: 1. 定义student类,私有数据成员字符数组name[20]; 2. 定义运算符<<,>>重载; 3. 在住函数中定义student 类数组s[N];并以输出和二进制的方式打开文件; ===================================================================== ===================================================================== Part2 1: 小型软件的开发(共占程序检查分的70%,学号的最后一位即选做的题号,最后一位是0则选做第10题,例如162181315号做的题目为第5题,162181310做的题目是第10题) 1.教职工信息管理 基本要求: 定义职工(employee )类,其中至少包括姓名、性别、工号、电话、所在系部和职称。 功能要求: 1、设计菜单实现功能选择; 2、输入功能:输入职工信息,并保存到文件中; 3、查询功能: 1)能够根据工号精确查询职工信息; 2)能够根据姓名、科室查询职工信息 3)分系部进行职称统计,计算各职称的人数 4、根据职工的职称排序输出 5、根据工号修改职工信息 6、根据工号删除职工信息
相关推荐: