C++實現(xiàn)考勤管理系統(tǒng)
本文實例為大家分享了C++實現(xiàn)考勤管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
設(shè)計一考勤管理系統(tǒng),記錄學(xué)生的缺課情況
1、設(shè)計學(xué)生類;
2、設(shè)計課程類;
3、設(shè)計考勤類;
4、錄入學(xué)生的缺課情況;
5、修改某個學(xué)生的缺課情況;
6、查詢某個學(xué)生的缺課情況;
7、統(tǒng)計一段時間內(nèi),曠課學(xué)生的名單和次數(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<<"---------吉林大學(xué)珠海學(xué)院---------\n"
?? ??? ??? ?<<" ? ? ? ? 學(xué)生考勤管理系統(tǒng)\n\n"
?? ??? ??? ?<<" ? ? ?1.錄入學(xué)生缺課信息\n"
?? ??? ??? ?<<" ? ? ?2.修改學(xué)生缺課記錄\n"
?? ??? ??? ?<<" ? ? ?3.查詢學(xué)生缺課情況\n"
?? ??? ??? ?<<" ? ? ?4.統(tǒng)計一段時間內(nèi)學(xué)生曠課情況\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<<"學(xué)生姓名:";
?? ??? ?cin>>name;?
?? ??? ?n[counter].setname(name);
?? ??? ?cout<<"學(xué)生學(xué)號:";
?? ??? ?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<<"請輸入學(xué)生學(xué)號:";
?? ??? ?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<<"無該學(xué)生缺課信息!\n"
?? ??? ??? ??? ?<<"請再次確認(rèn)輸入學(xué)號無誤\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<<"請輸入學(xué)生學(xué)號:";
?? ??? ?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é)號:"<<i[counter].getidentifynumber()
?? ??? ??? ??? ??? ??? ?<<"\n缺課課程名稱:"<<cn[counter].getcoursename()
?? ??? ??? ??? ??? ??? ?<<"\n缺課課程日期:"<<ct[counter].getcoursetime()
?? ??? ??? ??? ??? ??? ?<<"\n缺課時間:"<<cp[counter].getcourseplace()
?? ??? ??? ??? ??? ??? ?<<"\n缺課次數(shù):"<<*a[counter].getattendence()<<"\n";
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
?? ??? ??? ??? ?
?? ??? ?else
?? ??? ??? ?cout<<"無該同學(xué)數(shù)據(jù)";?
?? ??? ??? ??? ?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ù)據(jù)庫無信息\n\n";
?? ?
?? ?else if(totalnumber==1)
?? ?cout<<"學(xué)生姓名:"<<n[0].getname()
?? ??? ?<<"\n學(xué)生學(xué)號:"<<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<<"學(xué)生姓名:"<<n[att[index]].getname()
?? ??? ??? ??? ?<<"\n學(xué)生學(xué)號:"<<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;?
?? ??? ??? ?}
?? ??? ?}
?? ?}
}以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C++超詳細(xì)講解構(gòu)造函數(shù)與析構(gòu)函數(shù)的用法及實現(xiàn)
構(gòu)造函數(shù)主要作用在于創(chuàng)建對象時為對象的成員屬性賦值,構(gòu)造函數(shù)由編譯器自動調(diào)用,無須手動調(diào)用;析構(gòu)函數(shù)主要作用在于對象銷毀前系統(tǒng)自動調(diào)用,執(zhí)行一?些清理工作2022-05-05
C語言數(shù)據(jù)結(jié)構(gòu)之單向鏈表詳解分析
鏈表可以說是一種最為基礎(chǔ)的數(shù)據(jù)結(jié)構(gòu)了,而單向鏈表更是基礎(chǔ)中的基礎(chǔ)。鏈表是由一組元素以特定的順序組合或鏈接在一起的,不同元素之間在邏輯上相鄰,但是在物理上并不一定相鄰。在維護(hù)一組數(shù)據(jù)集合時,就可以使用鏈表,這一點和數(shù)組很相似2021-11-11
用C# 控制Windows系統(tǒng)音量的實現(xiàn)方法
本篇文章是對使用C#控制Windows系統(tǒng)音量的實現(xiàn)方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05

