C++實現(xiàn)考勤管理系統(tǒng)
更新時間:2022年03月16日 08:58:27 作者:我不叫喂喂喂喂喂喂喂喂喂
這篇文章主要介紹了C++實現(xiàn)考勤管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了C++實現(xiàn)考勤管理系統(tǒng)的具體代碼,供大家參考,具體內容如下
設計一考勤管理系統(tǒng),記錄學生的缺課情況
1、設計學生類;
2、設計課程類;
3、設計考勤類;
4、錄入學生的缺課情況;
5、修改某個學生的缺課情況;
6、查詢某個學生的缺課情況;
7、統(tǒng)計一段時間內,曠課學生的名單和次數(shù)
僅供參考,尚有不足,請多多指正!
#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" ?? ??? ??? ?<<" ? ? ? ? 學生考勤管理系統(tǒng)\n\n" ?? ??? ??? ?<<" ? ? ?1.錄入學生缺課信息\n" ?? ??? ??? ?<<" ? ? ?2.修改學生缺課記錄\n" ?? ??? ??? ?<<" ? ? ?3.查詢學生缺課情況\n" ?? ??? ??? ?<<" ? ? ?4.統(tǒng)計一段時間內學生曠課情況\n" ?? ??? ??? ?<<" ? ? ?5.退出系統(tǒng)\n\n" ?? ??? ??? ?<<"------------------------------"<<endl; ?? ??? ??? ??? ? ?? ??? ?int num; ?? ??? ?for(;;) ?? ??? ?{ ?? ??? ??? ?cout<<"請選擇需要執(zhí)行的功能序號(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<<"請輸入將錄入系統(tǒng)的人數(shù):";? ?? ??? ?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<<"課程時間(星期幾,第幾節(jié)課):"; ?? ??? ?cin>>coursetime; ?? ??? ?ct[counter].setcoursetime(coursetime); ?? ??? ?cout<<"課程地點:"; ?? ??? ?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<<"請輸入學生學號:"; ?? ??? ?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.缺課次數(shù)\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<<"請輸入修改后的課程時間(星期幾,第幾節(jié)課):"; ?? ??? ??? ??? ??? ??? ??? ?cin>>coursetime; ?? ??? ??? ??? ??? ??? ??? ?ct[counter].setcoursetime(coursetime); ?? ??? ??? ??? ??? ??? ??? ?cout<<'\n'; ?? ??? ??? ??? ??? ??? ??? ?break; ?? ??? ??? ??? ??? ??? ?} ?? ??? ??? ??? ??? ??? ? ?? ??? ??? ??? ??? ??? ?case 3:{ ?? ??? ??? ??? ??? ??? ??? ?cout<<"請輸入修改后的課程地點:"; ?? ??? ??? ??? ??? ??? ??? ?cin>>courseplace; ?? ??? ??? ??? ??? ??? ??? ?cp[counter].setcourseplace(courseplace); ?? ??? ??? ??? ??? ??? ??? ?cout<<'\n'; ?? ??? ??? ??? ??? ??? ??? ?break; ?? ??? ??? ??? ??? ??? ?} ?? ??? ??? ??? ??? ??? ? ?? ??? ??? ??? ??? ??? ?case 4:{ ?? ??? ??? ??? ??? ??? ??? ?cout<<"請輸入修改后的缺課次數(shù):"; ?? ??? ??? ??? ??? ??? ??? ?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缺課次數(shù):"<<*a[counter].getattendence()<<"\n"; ?? ??? ??? ??? ?} ?? ??? ??? ?} ?? ??? ?} ?? ??? ??? ??? ? ?? ??? ?else ?? ??? ??? ?cout<<"無該同學數(shù)據";? ?? ??? ??? ??? ?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<<"數(shù)據庫無信息\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缺課次數(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<<"學生姓名:"<<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缺課次數(shù):"<<*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++超詳細講解構造函數(shù)與析構函數(shù)的用法及實現(xiàn)
構造函數(shù)主要作用在于創(chuàng)建對象時為對象的成員屬性賦值,構造函數(shù)由編譯器自動調用,無須手動調用;析構函數(shù)主要作用在于對象銷毀前系統(tǒng)自動調用,執(zhí)行一?些清理工作2022-05-05用C# 控制Windows系統(tǒng)音量的實現(xiàn)方法
本篇文章是對使用C#控制Windows系統(tǒng)音量的實現(xiàn)方法進行了詳細的分析介紹,需要的朋友參考下2013-05-05