C++實(shí)現(xiàn)考勤管理系統(tǒng)
本文實(shí)例為大家分享了C++實(shí)現(xiàn)考勤管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
設(shè)計(jì)一考勤管理系統(tǒng),記錄學(xué)生的缺課情況
1、設(shè)計(jì)學(xué)生類;
2、設(shè)計(jì)課程類;
3、設(shè)計(jì)考勤類;
4、錄入學(xué)生的缺課情況;
5、修改某個(gè)學(xué)生的缺課情況;
6、查詢某個(gè)學(xué)生的缺課情況;
7、統(tǒng)計(jì)一段時(shí)間內(nèi),曠課學(xué)生的名單和次數(shù)
僅供參考,尚有不足,請(qǐng)多多指正!
#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<<"---------吉林大學(xué)珠海學(xué)院---------\n"
?? ??? ??? ?<<" ? ? ? ? 學(xué)生考勤管理系統(tǒng)\n\n"
?? ??? ??? ?<<" ? ? ?1.錄入學(xué)生缺課信息\n"
?? ??? ??? ?<<" ? ? ?2.修改學(xué)生缺課記錄\n"
?? ??? ??? ?<<" ? ? ?3.查詢學(xué)生缺課情況\n"
?? ??? ??? ?<<" ? ? ?4.統(tǒng)計(jì)一段時(shí)間內(nèi)學(xué)生曠課情況\n"
?? ??? ??? ?<<" ? ? ?5.退出系統(tǒng)\n\n"
?? ??? ??? ?<<"------------------------------"<<endl;
?? ??? ??? ??? ?
?? ??? ?int num;
?? ??? ?for(;;)
?? ??? ?{
?? ??? ??? ?cout<<"請(qǐng)選擇需要執(zhí)行的功能序號(hào)(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<<"----------請(qǐng)開始輸入----------\n";
?? ??? ?cout<<"請(qǐng)輸入將錄入系統(tǒng)的人數(shù):";?
?? ??? ?cin>>totalnumber;
?? ??? ?cout<<endl;
?? ?
?? ?for(int counter=0;counter<totalnumber;counter++)
?? ?{
?? ??? ?cout<<"學(xué)生姓名:";
?? ??? ?cin>>name;?
?? ??? ?n[counter].setname(name);
?? ??? ?cout<<"學(xué)生學(xué)號(hào):";
?? ??? ?cin>>identifynumber;
?? ??? ?i[counter].setidentifynumber(identifynumber);
?? ??? ?cout<<"課程名稱:";
?? ??? ?cin>>coursename;
?? ??? ?cn[counter].setcoursename(coursename);
?? ??? ?cout<<"課程時(shí)間(星期幾,第幾節(jié)課):";
?? ??? ?cin>>coursetime;
?? ??? ?ct[counter].setcoursetime(coursetime);
?? ??? ?cout<<"課程地點(diǎn):";
?? ??? ?cin>>courseplace;
?? ??? ?cp[counter].setcourseplace(courseplace);
?? ??? ?cout<<"缺課次數(shù):";
?? ??? ?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<<"請(qǐng)輸入學(xué)生學(xué)號(hào):";
?? ??? ?cin>>id;
?? ??? ?cout<<endl;
?? ?
?? ??? ?if(1)
?? ??? ?{
?? ??? ??? ?for(int counter=0;counter<totalnumber;counter++)
?? ??? ??? ?{
?? ??? ??? ??? ?if(strcmp(id,i[counter].getidentifynumber())==0)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?int num;
?? ??? ??? ??? ??? ?cout<<"請(qǐng)選擇需要修改信息的種類:"
?? ??? ??? ??? ??? ??? ?<<"\n1.課程名稱\n"
?? ??? ??? ??? ??? ??? ?<<"2.課程時(shí)間\n"
?? ??? ??? ??? ??? ??? ?<<"3.課程地點(diǎn)\n"
?? ??? ??? ??? ??? ??? ?<<"4.缺課次數(shù)\n";
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?for(;;)
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?cout<<"請(qǐng)輸入需要修改信息的代號(hào)(1-4):";
?? ??? ??? ??? ??? ??? ?cin>>num;
?? ??? ??? ??? ??? ??? ?if(num>=1&&num<=4)
?? ??? ??? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ??? ??? ?else
?? ??? ??? ??? ??? ??? ??? ?continue;
?? ??? ??? ??? ??? ?}?
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?cout<<endl;
?? ??? ??? ??? ?
?? ??? ??? ??? ??? ?switch(num){
?? ??? ??? ??? ??? ??? ?case 1:{
?? ??? ??? ??? ??? ??? ??? ?cout<<"請(qǐng)輸入修改后的課程名稱:";?
?? ??? ??? ??? ??? ??? ??? ?cin>>coursename;
?? ??? ??? ??? ??? ??? ??? ?cn[counter].setcoursename(coursename);
?? ??? ??? ??? ??? ??? ??? ?cout<<'\n';
?? ??? ??? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?case 2:{
?? ??? ??? ??? ??? ??? ??? ?cout<<"請(qǐng)輸入修改后的課程時(shí)間(星期幾,第幾節(jié)課):";
?? ??? ??? ??? ??? ??? ??? ?cin>>coursetime;
?? ??? ??? ??? ??? ??? ??? ?ct[counter].setcoursetime(coursetime);
?? ??? ??? ??? ??? ??? ??? ?cout<<'\n';
?? ??? ??? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?case 3:{
?? ??? ??? ??? ??? ??? ??? ?cout<<"請(qǐng)輸入修改后的課程地點(diǎn):";
?? ??? ??? ??? ??? ??? ??? ?cin>>courseplace;
?? ??? ??? ??? ??? ??? ??? ?cp[counter].setcourseplace(courseplace);
?? ??? ??? ??? ??? ??? ??? ?cout<<'\n';
?? ??? ??? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?case 4:{
?? ??? ??? ??? ??? ??? ??? ?cout<<"請(qǐng)輸入修改后的缺課次數(shù):";
?? ??? ??? ??? ??? ??? ??? ?cin>>attendence;
?? ??? ??? ??? ??? ??? ??? ?a[counter].setattendence(attendence);
?? ??? ??? ??? ??? ??? ??? ?array[counter]=attendence;
?? ??? ??? ??? ??? ??? ??? ?cout<<'\n';
?? ??? ??? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?}
?? ??? ??? ?}?
?? ??? ?}
?? ??? ??? ? ?? ??
?? ??? ?else
?? ??? ?{
?? ??? ??? ?cout<<"無該學(xué)生缺課信息!\n"
?? ??? ??? ??? ?<<"請(qǐng)?jiān)俅未_認(rèn)輸入學(xué)號(hào)無誤\n\n";
?? ??? ?}
?? ??? ??? ?
?? ??? ?for(;;)
?? ??? ?{
?? ??? ??? ?cout<<"重新查詢請(qǐng)輸入1|返回目錄請(qǐng)輸入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<<"請(qǐng)輸入學(xué)生學(xué)號(hào):";
?? ??? ?cin>>ids;
?? ??? ?cout<<endl;
?? ??? ?strcpy(ids,identify);
?? ?
?? ??? ?if(1)
?? ??? ?{
?? ??? ??? ?for(int counter=0;counter<totalnumber;counter++)
?? ??? ??? ?{
?? ??? ??? ??? ?if(strcmp(ids,i[counter].getidentifynumber())==0)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?cout<<"學(xué)生姓名:"<<n[counter].getname()
?? ??? ??? ??? ??? ??? ?<<"\n學(xué)生學(xué)號(hào):"<<i[counter].getidentifynumber()
?? ??? ??? ??? ??? ??? ?<<"\n缺課課程名稱:"<<cn[counter].getcoursename()
?? ??? ??? ??? ??? ??? ?<<"\n缺課課程日期:"<<ct[counter].getcoursetime()
?? ??? ??? ??? ??? ??? ?<<"\n缺課時(shí)間:"<<cp[counter].getcourseplace()
?? ??? ??? ??? ??? ??? ?<<"\n缺課次數(shù):"<<*a[counter].getattendence()<<"\n";
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
?? ??? ??? ??? ?
?? ??? ?else
?? ??? ??? ?cout<<"無該同學(xué)數(shù)據(jù)";?
?? ??? ??? ??? ?break;
?? ??? ?
?? ??? ?cout<<'\n'<<endl;
?? ??? ?for(;;)
?? ??? ?{
?? ??? ??? ?cout<<"重新查詢請(qǐng)輸入1|返回目錄請(qǐng)輸入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<<"數(shù)據(jù)庫無信息\n\n";
?? ?
?? ?else if(totalnumber==1)
?? ?cout<<"學(xué)生姓名:"<<n[0].getname()
?? ??? ?<<"\n學(xué)生學(xué)號(hào):"<<i[0].getidentifynumber()
?? ??? ?<<"\n缺課課程名稱:"<<cn[0].getcoursename()
?? ??? ?<<"\n缺課課程日期:"<<ct[0].getcoursetime()
?? ??? ?<<"\n缺課時(shí)間:"<<cp[0].getcourseplace()
?? ??? ?<<"\n缺課次數(shù):"<<*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<<"學(xué)生姓名:"<<n[att[index]].getname()
?? ??? ??? ??? ?<<"\n學(xué)生學(xué)號(hào):"<<i[att[index]].getidentifynumber()
?? ??? ??? ??? ?<<"\n缺課課程名稱:"<<cn[att[index]].getcoursename()
?? ??? ??? ??? ?<<"\n缺課課程日期:"<<ct[att[index]].getcoursetime()
?? ??? ??? ??? ?<<"\n缺課時(shí)間:"<<cp[att[index]].getcourseplace()
?? ??? ??? ??? ?<<"\n缺課次數(shù):"<<*a[att[index]].getattendence()<<"\n\n";
?? ??? ?}
?? ??? ?
?? ?}
?? ?
?? ?cout<<"返回目錄請(qǐng)輸入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;?
?? ??? ??? ?}
?? ??? ?}
?? ?}
}以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C++ Boost Container庫示例詳細(xì)講解
Boost是為C++語言標(biāo)準(zhǔn)庫提供擴(kuò)展的一些C++程序庫的總稱。Boost庫是一個(gè)可移植、提供源代碼的C++庫,作為標(biāo)準(zhǔn)庫的后備,是C++標(biāo)準(zhǔn)化進(jìn)程的開發(fā)引擎之一,是為C++語言標(biāo)準(zhǔn)庫提供擴(kuò)展的一些C++程序庫的總稱2022-11-11
FFmpeg實(shí)現(xiàn)多線程編碼并保存mp4文件
這篇文章主要為大家介紹了FFmpeg如何持續(xù)的從指定內(nèi)存中讀取原始數(shù)據(jù),再將解碼數(shù)據(jù)存入隊(duì)列中,并通過單獨(dú)的線程進(jìn)行編碼,最后保存為mp4文件,感興趣的可以了解下2023-08-08
Matlab實(shí)現(xiàn)三維投影繪制的示例代碼
這篇文章系小編為大家?guī)砹艘粋€(gè)三維投影繪制函數(shù)(三視圖繪制),函數(shù)支持三維曲線、曲面、三維多邊形、參數(shù)方程曲線、參數(shù)方程曲面的投影繪制,需要的可以參考一下2022-08-08
C語言實(shí)現(xiàn)切片數(shù)組的示例詳解
由于c語言沒有集合類的標(biāo)準(zhǔn)庫,需要用時(shí)只能自己實(shí)現(xiàn),所以本文參考了go語言的slice,找到了一種非常簡化的動(dòng)態(tài)數(shù)組接口,下面我們就來看看如何在C語言中實(shí)現(xiàn)切片吧2024-03-03
模擬鼠標(biāo)事件的實(shí)現(xiàn)思路及代碼
這篇文章主要介紹了模擬鼠標(biāo)事件的實(shí)現(xiàn)思路及代碼,有需要的朋友可以參考一下2013-12-12

