文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

C++如何实现考勤管理系统

2023-06-29 12:58

关注

本篇内容主要讲解“C++如何实现考勤管理系统”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“C++如何实现考勤管理系统”吧!

设计一考勤管理系统,记录学生的缺课情况

设计学生类;
2、设计课程类;
3、设计考勤类;
4、录入学生的缺课情况;
5、修改某个学生的缺课情况;
6、查询某个学生的缺课情况;
7、统计一段时间内,旷课学生的名单和次数

仅供参考,尚有不足,请多多指正!

#include <iostream>#include <cstring>using namespace std;class Student{    public:        void setname(char *setname)        {                strcpy(name,setname);        }                void setcarname(char *setcarname)        {            strcpy(carname,setcarname);        }                void setseating_capacity(char *setseating_capacity)        {            strcpy(seating_capacity,setseating_capacity);        }                void setidentifynumber(char *setidentifynumber)        {            strcpy(identifynumber,setidentifynumber);        }                 char *getname()        {            char *setname=name;            return setname;        }                char *getcarname()        {            char *setcarname=carname;            return setcarname;        }                char *getsetseating_capacity()        {            char *setseating_capacity=seating_capacity;            return setseating_capacity;        }                char *getidentifynumber()        {            char *setidentifynumber=identifynumber;            return setidentifynumber;        }                    private:        char name[30];        char carname[30];        char seating_capacity[30];        char identifynumber[30];};class Course:public Student{    public:        void setcoursename(char *setcoursename)        {            strcpy(coursename,setcoursename);        }                void setcoursetime(char *setcoursetime)        {            strcpy(coursetime,setcoursetime);        }                  void setcourseplace(char *setcourseplace)        {            strcpy(courseplace,setcourseplace);        }                char *getcoursename()        {            char *setcoursename;            setcoursename=coursename;            return setcoursename;        }                char *getcoursetime()        {            char *setcoursetime;            setcoursetime=coursetime;            return setcoursetime;        }                char *getcourseplace()        {            char *setcourseplace;            setcourseplace=courseplace;            return setcourseplace;        }            private:        char coursename[30];        char coursetime[30];        char courseplace[30];}; class Attendence:public Course{    public:        void setattendence(int setattendence)        {            int i=0;            attendence[i]=setattendence;            i++;        }                int *getattendence()        {            int *setattendence;            setattendence=attendence;            return setattendence;        }    private:        int attendence[30];}; int input(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[]);int modify(Student i[],Course cn[],Course ct[],Course cp[],Attendence attendence[],int totalnumber);int search(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber);int statistic(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber);void bubble(int arr[],int len);Student n[20];Student i[20];Course cn[20];Course ct[20];Course cp[20];Attendence a[20];int totalnumber=0;char name[30];char identifynumber[30];char coursename[30];char coursetime[30];char courseplace[30];int attendence;int array[30];int att[30];int main() {    while(1)    {        cout<<"---------吉林大学珠海学院---------\n"            <<"         学生考勤管理系统\n\n"            <<"      1.录入学生缺课信息\n"            <<"      2.修改学生缺课记录\n"            <<"      3.查询学生缺课情况\n"            <<"      4.统计一段时间内学生旷课情况\n"            <<"      5.退出系统\n\n"            <<"------------------------------"<<endl;                        int num;        for(;;)        {            cout<<"请选择需要执行的功能序号(1-5):";            cin>>num;            if(num>=1&&num<=5)                break;            else                continue;        }                cout<<endl;            switch(num){            case 1:{                input(n,i,cn,ct,cp,a);                break;            }                        case 2:{                modify(i,cn,ct,cp,a,totalnumber);                break;            }                        case 3:{                search(n,i,cn,ct,cp,a,totalnumber);                break ;            }                                    case 4:{                statistic(n,i,cn,ct,cp,a,totalnumber);                break;            }                        case 5:exit(0);         }    }    }int input(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[]){    cout<<"----------请开始输入----------\n";        cout<<"请输入将录入系统的人数:";         cin>>totalnumber;        cout<<endl;        for(int counter=0;counter<totalnumber;counter++)    {        cout<<"学生姓名:";        cin>>name;         n[counter].setname(name);        cout<<"学生学号:";        cin>>identifynumber;        i[counter].setidentifynumber(identifynumber);        cout<<"课程名称:";        cin>>coursename;        cn[counter].setcoursename(coursename);        cout<<"课程时间(星期几,第几节课):";        cin>>coursetime;        ct[counter].setcoursetime(coursetime);        cout<<"课程地点:";        cin>>courseplace;        cp[counter].setcourseplace(courseplace);        cout<<"缺课次数:";        cin>>attendence;        a[counter].setattendence(attendence);        array[counter]=attendence;        cout<<'\n';    }        return 1;}int modify(Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber){    int inputnumber;    do{        char id[8];        cout<<"请输入学生学号:";        cin>>id;        cout<<endl;            if(1)        {            for(int counter=0;counter<totalnumber;counter++)            {                if(strcmp(id,i[counter].getidentifynumber())==0)                {                    int num;                    cout<<"请选择需要修改信息的种类:"                        <<"\n1.课程名称\n"                        <<"2.课程时间\n"                        <<"3.课程地点\n"                        <<"4.缺课次数\n";                                            for(;;)                    {                        cout<<"请输入需要修改信息的代号(1-4):";                        cin>>num;                        if(num>=1&&num<=4)                            break;                        else                            continue;                    }                                         cout<<endl;                                    switch(num){                        case 1:{                            cout<<"请输入修改后的课程名称:";                             cin>>coursename;                            cn[counter].setcoursename(coursename);                            cout<<'\n';                            break;                        }                                                case 2:{                            cout<<"请输入修改后的课程时间(星期几,第几节课):";                            cin>>coursetime;                            ct[counter].setcoursetime(coursetime);                            cout<<'\n';                            break;                        }                                                case 3:{                            cout<<"请输入修改后的课程地点:";                            cin>>courseplace;                            cp[counter].setcourseplace(courseplace);                            cout<<'\n';                            break;                        }                                                case 4:{                            cout<<"请输入修改后的缺课次数:";                            cin>>attendence;                            a[counter].setattendence(attendence);                            array[counter]=attendence;                            cout<<'\n';                            break;                        }                                            }                }            }         }                          else        {            cout<<"无该学生缺课信息!\n"                <<"请再次确认输入学号无误\n\n";        }                    for(;;)        {            cout<<"重新查询请输入1|返回目录请输入0\n";             cin>>inputnumber;            if(inputnumber==1||inputnumber==0)                break;            else                continue;        }                    }while(inputnumber==1);        return 1;}int search(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber){    int inputnumber;    do{        char ids[8];        char *identify=ids;        cout<<"请输入学生学号:";        cin>>ids;        cout<<endl;        strcpy(ids,identify);            if(1)        {            for(int counter=0;counter<totalnumber;counter++)            {                if(strcmp(ids,i[counter].getidentifynumber())==0)                {                    cout<<"学生姓名:"<<n[counter].getname()                        <<"\n学生学号:"<<i[counter].getidentifynumber()                        <<"\n缺课课程名称:"<<cn[counter].getcoursename()                        <<"\n缺课课程日期:"<<ct[counter].getcoursetime()                        <<"\n缺课时间:"<<cp[counter].getcourseplace()                        <<"\n缺课次数:"<<*a[counter].getattendence()<<"\n";                }            }        }                        else            cout<<"无该同学数据";                 break;                cout<<'\n'<<endl;        for(;;)        {            cout<<"重新查询请输入1|返回目录请输入0\n\n";            cin>>inputnumber;            if(inputnumber==0||inputnumber==1)                break;            else                continue;        }            }while(inputnumber==1);        return 1;}int statistic(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber){    int inputnumber;    for(int index=0;index<30;index++)        att[index]=index;        if(totalnumber==0)    cout<<"数据库无信息\n\n";        else if(totalnumber==1)    cout<<"学生姓名:"<<n[0].getname()        <<"\n学生学号:"<<i[0].getidentifynumber()        <<"\n缺课课程名称:"<<cn[0].getcoursename()        <<"\n缺课课程日期:"<<ct[0].getcoursetime()        <<"\n缺课时间:"<<cp[0].getcourseplace()        <<"\n缺课次数:"<<*a[0].getattendence()<<"\n\n";        else if(1)    {        for(int counter=0;counter<totalnumber;counter++)        {            if(a[counter].getattendence()<a[counter].getattendence()+1)            {                bubble(array,totalnumber);            }                        else if(a[counter].getattendence()==a[counter+1].getattendence())            {                if(strcmp(i[counter].getidentifynumber(),i[counter+1].getidentifynumber())>0)                {                    int temp;                    int a=counter;                    int b=counter+1;                                        temp=a;                    a=b;                    b=temp;                }            }                    }        for(int index=0;index<totalnumber;index++)        {            cout<<"学生姓名:"<<n[att[index]].getname()                <<"\n学生学号:"<<i[att[index]].getidentifynumber()                <<"\n缺课课程名称:"<<cn[att[index]].getcoursename()                <<"\n缺课课程日期:"<<ct[att[index]].getcoursetime()                <<"\n缺课时间:"<<cp[att[index]].getcourseplace()                <<"\n缺课次数:"<<*a[att[index]].getattendence()<<"\n\n";        }            }        cout<<"返回目录请输入0\n";    cin>>inputnumber;    if(inputnumber==0)        return 1;}void bubble(int arr[],int len){    int i,j,temp;    int t;    for(i=0;i<len-1;i++)    {        for(j=0;j<len-1-i;j++)        {            if(arr[j]<arr[j+1])            {                temp=arr[j];                arr[j]=arr[j+1];                arr[j+1]=temp;                                t=att[j];                att[j]=att[j+1];                att[j+1]=t;             }        }    }}

到此,相信大家对“C++如何实现考勤管理系统”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯