简易学生教师管理系统

实验一

1. 实验内容
简易学生教师管理系统。

C++
 

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

class People {
public:
    string no;
    string name;
};

class Student : public People {
public:
    int age;
    void set(string nono, string namename, int ageage);
    void out(Student S);
};

class Teacher : public People {
public:
    float salary;
    string title;
    void set(string nono, string namename,float salarysalary, string titletitle);
    void out(Teacher T);
};

// 成员函数定义
void Student::set(string nono, string namename, int ageage){
    no = nono;
    name = namename;
    age = ageage;
}

void Student::out(Student S) {
    cout << "编号:" << S.no << endl;
    cout << "姓名:" << S.name << endl;
    cout << "年龄:" << S.age << endl;
    cout << endl;
}

void Teacher::set(string nono, string namename, float salarysalary, string titletitle) {
    no = nono;
    name = namename;
    salary = salarysalary;
    title = titletitle;
}

void Teacher::out(Teacher T) {
    cout << "编号:" << T.no << endl;
    cout << "姓名:" << T.name << endl;
    cout << "薪水:" << T.salary << endl;
    cout << "职称:" << T.title << endl;
    cout << endl;
}

struct StudentListNode
{
    Student value;
    StudentListNode* next;
    //构造函数
    StudentListNode(Student valuevalue, StudentListNode* nextnext = NULL)
    {
        value = valuevalue;
        next = nextnext;
    }
};

struct TeacherListNode
{
    Teacher value;
    TeacherListNode* next;
    //构造函数
    TeacherListNode(Teacher valuevalue, TeacherListNode* nextnext = NULL)
    {
        value = valuevalue;
        next = nextnext;
    }
};


void setteacher(TeacherListNode* TL) {
    //cout << endl << endl;
    cout << ">>创建教师信息" << endl;
    Teacher T;
    cout << ">>输入编号:";
    cin >> T.no;
    cout << ">>输入姓名:";
    cin >> T.name;
    cout << ">>输入薪水:";
    cin >> T.salary;
    cout << ">>输入职称:";
    cin >> T.title;
    TeacherListNode* TT = new TeacherListNode(T);

    TeacherListNode* ptr = TL;
    TeacherListNode* ptr2 = TL;
    while (ptr != NULL) {
        ptr2 = ptr;
        ptr = ptr->next; //移动到下一个结点
    }
    ptr2->next = TT;
}

void setstudent(StudentListNode* SL) {
    //cout << endl << endl;
    cout << ">>创建学生信息" << endl;
    Student S;
    cout << ">>输入编号:";
    cin >> S.no;
    cout << ">>输入姓名:";
    cin >> S.name;
    cout << ">>输入年龄:";
    cin >> S.age;
    StudentListNode* SS = new StudentListNode(S);

    StudentListNode* ptr = SL;
    StudentListNode* ptr2 = SL;
    while (ptr != NULL) {
        ptr2 = ptr;
        ptr = ptr->next; //移动到下一个结点
    }
    ptr2->next = SS;
}

void seeteacher(TeacherListNode* TL) {
    TeacherListNode* ptr = TL;
    ptr = ptr->next;
    while (ptr != NULL) {
        ptr->value.out(ptr->value);
        ptr = ptr->next; //移动到下一个结点
    }
}
void seestudent(StudentListNode* SL) {
    StudentListNode* ptr = SL;
    ptr = ptr->next;
    while (ptr != NULL) {
        ptr->value.out(ptr->value);
        ptr = ptr->next; //移动到下一个结点
    }
}

TeacherListNode* findteacher(TeacherListNode* TL,string ff,bool k) {//k==0 使用姓名
    TeacherListNode* ptr =
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值