学生学籍信息管理系统


#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <iterator>
#include <string>
using namespace std;
struct course
{
    vector<string> course_name;            //课程名
    vector<string> course_ID;            //课程号
    vector<int> course_credit_hour;        //课程学分
};
struct mark
{
    vector<int> V_H_mark;        //平时成绩
    vector<int> V_E_mark;        //实验成绩
    vector<int> V_P_mark;        //卷面成绩
    vector<int> V_T_mark;        //综合成绩
    vector<int> V_C_hour;        //学分
};
struct student
{
    string ID;                    //学号
    string Name;                //学生名字
    string Sex;                    //性别
    string Dorm_NO;                //宿舍号
    string Phone_NO;            //电话号码
    int Total_credit_hour;        //所修课程总学分
    course student_course;
    mark Student_mark;
};
vector
<student> V_student;
//显示程序友好界面
void face()
{
    cout<<setw(8)<<setfill(' ')<<' '<<setw(66)<<setfill('*')<<'*'<<endl;
    cout<<setw(8)<<setfill(' ')<<' '<<setw(20)<<setfill('*')
        <<'*'<<setw(26)<<setfill(' ')<<' '<<setw(20)<<setfill('*')<<'*'<<endl;
    cout<<setw(31)<<setfill(' ')<<' '<<"Welcome to use SIMS"<<endl;
    cout<<setw(8)<<setfill(' ')<<' '<<setw(20)<<setfill('*')
        <<'*'<<setw(26)<<setfill(' ')<<' '<<setw(20)<<setfill('*')<<'*'<<endl;
    cout<<setw(8)<<setfill(' ')<<' '<<setw(66)<<setfill('*')<<'*'<<endl;
}
//添加学生的基本信息
void add()
{
    student p_student;string str;
    cout<<setw(8)<<setfill(' ')<<' '<<setw(23)<<setfill('*')<<'*'
        <<" Add a  new student "<<setw(23)<<setfill('*')<<'*'<<endl;
    cout<<setw(10)<<setfill(' ')<<' '<<"ID:";
    cin>>str;
    p_student.ID=str;
    cout<<setw(10)<<setfill(' ')<<' '<<"Name:";
    cin>>str;
    p_student.Name =str;
    cout<<setw(10)<<setfill(' ')<<' '<<"Sex(g/b):";
    cin>>str;
    p_student.Sex =str;
    cout<<setw(10)<<setfill(' ')<<' '<<"Dorm number:";
    cin>>str;
    p_student.Dorm_NO =str;
    cout<<setw(10)<<setfill(' ')<<' '<<"Phone number:";
    cin>>str;
    p_student.Phone_NO =str;
    //p_student.Total_credit_hour=0;
    V_student.push_back (p_student);
}
//显示所有学生的基本信息
void show()
{
    cout<<setw(8)<<setfill(' ')<<' '<<setw(66)<<setfill('*')<<'*'<<endl;
    cout.setf (ios::left);
    cout<<setw(10)<<setfill(' ')<<' '
        <<setw(15)<<"ID"
        <<setw(15)<<"Name"
        <<setw(5)<<"Sex"
        <<setw(12)<<"Dorm Number"
        <<setw(15)<<"Phone Number"<<endl;
    for(int i=0;i<V_student.size();i++)
    {
        cout<<setw(10)<<setfill(' ')<<' '
            <<setw(15)<<V_student.at(i).ID
            <<setw(15)<<V_student.at(i).Name
            <<setw(5)<<V_student.at(i).Sex
            <<setw(12)<<V_student.at(i).Dorm_NO
            <<setw(15)<<V_student.at(i).Phone_NO<<endl;
    }
}
void calculate()
{
    int i=0,j=0;
    for(i=0;i<V_student.size ();i++)
    {
        V_student.at(i).Total_credit_hour =0;
        for(j=00;j<V_student.at(i).student_course.course_ID.size ();j++)
        {
            //计算分数
            if(V_student.at(i).Student_mark.V_E_mark.at(j)==-1)
                //无实验
                V_student.at(i).Student_mark.V_T_mark.push_back (
                    V_student.at(i).Student_mark.V_H_mark.at(j)*0.3+
                    V_student.at(i).Student_mark.V_P_mark.at(j)*0.7);
            else V_student.at(i).Student_mark.V_T_mark.push_back (
                V_student.at(i).Student_mark.V_E_mark.at(j)*0.15+
                V_student.at(i).Student_mark.V_H_mark.at(j)*0.15+
                V_student.at(i).Student_mark.V_P_mark.at(j)*0.7);
            //计算学分
            if(V_student.at(i).Student_mark.V_T_mark.at(j)>=90
                &&V_student.at(i).Student_mark.V_T_mark.at(j)<=100)
                V_student.at(i).Student_mark.V_C_hour.push_back (
                V_student.at(i).student_course.course_credit_hour.at(j));
            else if(V_student.at(i).Student_mark.V_T_mark.at(j)>=80
                &&V_student.at(i).Student_mark.V_T_mark.at(j)<90)
                V_student.at(i).Student_mark.V_C_hour.push_back (
                V_student.at(i).student_course.course_credit_hour.at(j)*0.8);
            else if(V_student.at(i).Student_mark.V_T_mark.at(j)>=70
                &&V_student.at(i).Student_mark.V_T_mark.at(j)<80)
                V_student.at(i).Student_mark.V_C_hour.push_back (
                V_student.at(i).student_course.course_credit_hour.at(j)*0.75);
            else if(V_student.at(i).Student_mark.V_T_mark.at(j)>=60
                &&V_student.at(i).Student_mark.V_T_mark.at(j)<70)
                V_student.at(i).Student_mark.V_C_hour.push_back (
                V_student.at(i).student_course.course_credit_hour.at(j)*0.6);
            else V_student.at(i).Student_mark.V_C_hour.push_back (0);
            //计算总学分
            V_student.at(i).Total_credit_hour += V_student.at(i).Student_mark.V_C_hour.at(j);
        }   
    }

}
//通过ID查找一个学生的详细信息
void find()
{
    string str;
    cout<<setw(8)<<setfill(' ')<<' '<<setw(23)<<setfill('*')<<'*'
        <<"Find a student by ID"<<setw(23)<<setfill('*')<<'*'<<endl;
    cout<<setw(10)<<setfill(' ')<<' '<<"The ID:";
    cin>>str;
    //计算学分
    calculate();
    //查找
    for(int i=0;i<V_student.size();i++)
        if(V_student.at(i).ID ==str)
        {
            cout.setf (ios::left);
            cout<<setw(8)<<setfill(' ')<<' '<<"Student:"<<endl;
            cout<<setw(10)<<setfill(' ')<<' '
            <<setw(15)<<"ID"
            <<setw(15)<<"Name"
            <<setw(5)<<"Sex"
            <<setw(12)<<"Dorm Number"
            <<setw(15)<<"Phone Number"<<endl;
            cout<<setw(10)<<setfill(' ')<<' '
            <<setw(15)<<V_student.at(i).ID
            <<setw(15)<<V_student.at(i).Name
            <<setw(5)<<V_student.at(i).Sex
            <<setw(12)<<V_student.at(i).Dorm_NO
            <<setw(15)<<V_student.at(i).Phone_NO<<endl;
            //分数
            cout<<setw(8)<<setfill(' ')<<' '<<"Mark:"<<endl;
            cout<<setw(8)<<setfill(' ')<<' '<<setw(20)<<"Course Name"
            <<setw(15)<<"Mark"<<setw(15)<<"Credit_hour"<<endl;
            for(int j=0;j<V_student.at(i).student_course.course_name.size();j++)
            {
                cout<<setw(8)<<setfill(' ')<<' '
                    <<setw(20)<<V_student.at(i).student_course.course_name.at(j)
                    <<setw(15)<<V_student.at(i).Student_mark.V_T_mark.at(j)
                    <<setw(15)<<V_student.at(i).Student_mark.V_C_hour.at(j)<<endl;
            }
            cout<<setw(8)<<setfill(' ')<<' '<<"Total Credit_hour: "
                <<V_student.at(i).Total_credit_hour<<endl;
            return;
        }
    cout<<setw(10)<<setfill(' ')<<' '<<"This ID does not exist"<<endl;
}
//通过名字删除学生的信息
void remove()
{
    string str;
    cout<<setw(8)<<setfill(' ')<<' '<<setw(23)<<setfill('*')<<'*'
        <<"Remove   a   student"<<setw(23)<<setfill('*')<<'*'<<endl;
    cout<<setw(10)<<setfill(' ')<<' '<<"To remove,enter name:";
    cin>>str;
    for(int i=0;i<V_student.size ();i++)
        if(str==V_student.at(i).Name )
        {
            V_student.erase (V_student.begin ()+i);
            cout<<setw(10)<<setfill(' ')<<' '<<"Remove sucessfully!"<<endl;
            return;
        }
    cout<<setw(10)<<setfill(' ')<<' '<<"The name does not exist!"<<endl;
}
//总成绩与单课学分计算    计算总学分

void record()
{
    string str;int temp;char ch='y';
    cout<<setw(8)<<setfill(' ')<<' '<<setw(23)<<setfill('*')<<'*'
        <<"Record students mark"<<setw(23)<<setfill('*')<<'*'<<endl;
    cout<<setw(10)<<setfill(' ')<<' '<<"Student ID:";
    cin>>str;
    for(int i=0;i<V_student.size ();i++)
    {
        if(str==V_student.at(i).ID )
        {
            while('y'==ch)
            {
                //输入所修课程
                cout<<setw(10)<<setfill(' ')<<' '<<"Course ID:";
                cin>>str;
                V_student.at(i).student_course.course_ID.push_back (str);
                cout<<setw(10)<<setfill(' ')<<' '<<"Course Name:";
                cin>>str;
                V_student.at(i).student_course.course_name.push_back (str);
                //实验成绩为-1,表示该课程没有实验
                cout<<setw(10)<<setfill(' ')<<' '<<"Experiment mark:";
                cin>>temp;
                V_student.at(i).Student_mark.V_E_mark.push_back (temp);
                cout<<setw(10)<<setfill(' ')<<' '<<"Paper_test mark:";
                cin>>temp;
                V_student.at(i).Student_mark.V_P_mark.push_back (temp);
                cout<<setw(10)<<setfill(' ')<<' '<<"Hortation mark:";
                cin>>temp;
                V_student.at(i).Student_mark.V_H_mark.push_back (temp);
                cout<<setw(10)<<setfill(' ')<<' '<<"Course Credit_hour:";
                cin>>temp;
                V_student.at(i).student_course.course_credit_hour.push_back (temp);
                cout<<setw(8)<<setfill(' ')<<' '<<"continute?(y/n):";
                cin>>ch;
            }
            return;
        }
    }
   
}
//按总学分升序排列
//加权值
void sort()   
{
    int i=0,j=0,k=V_student.size ();
    int *V_int=new int[k];
    cout<<setw(8)<<setfill(' ')<<' '<<setw(23)<<setfill('*')<<'*'
        <<" Sort by ascendance "<<setw(23)<<setfill('*')<<'*'<<endl;
    for(i=0;i<k;i++)V_int[i]=0;
    for(i=0;i<k;i++)   
    {
        for(int j=0;j<k;j++)   
        {
            if(V_student.at(i).Total_credit_hour<V_student.at(j).Total_credit_hour )
                V_int[j] ++;
               
        }
    }
    cout.setf (ios::left);
    cout<<setw(15)<<setfill(' ')<<' '
        <<setw(15)<<"ID"
        <<setw(15)<<"Name"
        <<setw(15)<<"Total Credit_hour"<<endl;
    for(i=0;i<k;i++)
    {
        for(j=0;j<k;j++)
        {
            if(i==V_int[j])
            {       
                cout<<setw(15)<<setfill(' ')<<' '
                    <<setw(15)<<V_student.at(j).ID
                    <<setw(15)<<V_student.at(j).Name
                    <<setw(15)<<V_student.at(j).Total_credit_hour <<endl;

            }
        }
    }
}
void menu_choice(char ch);
//显示程序的菜单
void menu()
{
    char ch;
    cout<<setw(8)<<setfill(' ')<<' '
        <<setw(31)<<setfill('*')<<'*'<<"Menu"
        <<setw(31)<<setfill('*')<<'*'<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"1>Add new student"<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"2>Show all students"<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"3>Find a student"<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"4>Remove a student"<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"5>Record mark"<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"6>Sort by order"<<endl;
    cout<<setw(30)<<setfill(' ')<<' '<<"7>EXIT"<<endl;
    cout<<setw(10)<<setfill(' ')<<' '<<"Founction Choice:";
    cin>>ch;
    menu_choice(ch);
}
//选择菜单
void menu_choice(char ch)       
{
       
    switch(ch)
    {
    case '1': add();break;
    case '2': show();break;
    case '3': find();break;
    case '4': remove();break;
    case '5': record();break;
    case '6': sort();break;
    case '7': exit(1);
    default:
        cout<<setw(10)<<setfill(' ')<<' '<<"Unrealize key!"<<endl;break;
    }
    menu();
}

void main()
{
    face();
    menu();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值