c++,考勤管理系统

img

windows,不用模板来完成,尽可能简单,注释要详细且直观
,初学者第一次提问,多多指教

这种管理系统可以去gitee或者github上直接找来参考,不需要花这个钱💰

这是老师从哪抄的,还没抄清楚,学生类整个车名,载客人数,也就醉了。

img


#include<iostream>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
#define N 999
int n;
class STU
{
public:
    STU() {}
    void input(char d[],int X,string n,string sn,int sd,int cl)
    {
        strcpy(date,d);
        ClassX=X;
        ClassN=n;
        stuN=sn;
        stuID=sd;
        ClassL=cl;
    }
    void print()
    {
        cout<<"缺课日期 课节 课程名称 学生姓名 学生学号 缺课类型\t"<<endl;
        cout<<date<<"\t"<<ClassX<<"\t"<<ClassN<<"\t"<<stuN<<"\t"<<stuID<<"\t"<<ClassL<<endl;
    }
    friend void Change(STU stu[]);
    friend void Find(STU stu[]);
    friend void chaxun1(STU stu[]);
    friend void chaxun2(STU stu[]);
private:
    string  stuN;
    int  stuID;
    char date[15];
    int  ClassX;
    string ClassN;
    int  ClassL;
};

//主菜单
void meau()
{
    cout<<endl;
    cout<<endl;
    cout<<"学生后勤管理系统"<<endl;
    cout<<"1-录入学生的缺课记录"<<endl;
    cout<<"2-修改某个学生的缺课记录"<<endl;
    cout<<"3-查询某个学生的缺课情况"<<endl;
    cout<<"4-统计旷课信息"<<endl;
    cout<<"5-退出系统"<<endl;
    cout<<endl;
    cout<<endl;

}
//输入学生的缺课记录
void Input(STU stu[])
{
    char date[15];
    string stuN, ClassN;
    int  stuID,ClassX,ClassL;
    while(1)
    {
        cout<<"请输入记录情况个数"<<endl;
        cin>>n;
        for(int i=0; i<n; i++)
        {
            cout<<"请输入第"<<i+1<<"种情况"<<endl;
            cout<<"请输入缺课日期\n";
            cin>>date;
            cout<<"请输入第几节课\n";
            cin>>ClassX;
            cout<<"请输入课程名称\n";
            cin>>ClassN;
            cout<<"请输入学生姓名\n";
            cin>>stuN;
            cout<<"请输入学生学号\n";
            cin>>stuID;
            cout<<"请输入缺课类型,1代表请假,2代表旷课, 3代表迟到\n";
            cin>>ClassL;
            stu[i].input(date,ClassX,ClassN,stuN,stuID,ClassL);
        }
        cout<<"输入信息完毕!是否继续输入?y是继续,n是停止:"<<endl;
        char cc;
        getchar();
        cin>>cc;
        if(cc=='n')
            return ;
    }
}
//修改某个学生的缺课记录
void Change(STU stu[])
{
    cout<<"请输入将要修改的学生姓名或者学号,1代表姓名,2代表学号:"<<endl;
    int x;
    cin>>x;
    if(x==1)
    {
        cout<<"请输入将要修改的学生姓名:"<<endl;
        string name;
        cin>>name;
        for(int i=0; i<n; i++)
        {
            if(stu[i].stuN==name)
            {
                stu[i].print();
                cout<<"是否对该学生信息进行修改,y代表进行,n代表不进行:"<<endl;
                getchar();
                char cc;
                cin>>cc;
                if(cc=='n')
                    continue;
                else if(cc='y')
                {
                    cout<<"请选择修改内容:"<<endl;
                    cout<<"修改日期请按1:\n修改课节请按2:\n修改课程名称请按3:\n修改缺课类型请按4:\n";
                    cin>>x;
                    switch(x)
                    {
                    case 1:
                    {
                        char date[20];
                        cout<<"请输入正确日期"<<endl;
                        cin>>date;
                        strcpy(stu[i].date,date);
                    }
                    break;
                    case 2:
                    {
                        cout<<"请输入正确课节"<<endl;
                        cin>>x;
                        stu[i].ClassX=x;
                    }
                    break;
                    case 3:
                    {
                        cout<<"请输入正确课程名称"<<endl;
                        cin>>name;
                        stu[i].ClassN=name;
                    }
                    break;
                    case 4:
                    {
                        cout<<"请输入正确缺课类型"<<endl;
                        cin>>x;
                        stu[i].ClassL=x;
                    }
                    break;
                    default :
                        cout<<"抱歉,没有该选项。"<<endl;
                    }
                    break;
                    cout<<"输出修改后的学生信息:"<<endl;
                    stu[i].print();
                }
                else cout<<"抱歉,没有该选项。"<<endl;
            }
        }
    }
    else if(x==2)
    {
        cout<<"请输入要修改的学号:"<<endl;
        cin>>x;
        for(int i=0; i<n; i++)
        {
            if(stu[i].stuID==x)
            {
                cout<<"是否对该学生信息进行修改,y代表进行,n代表不进行:"<<endl;
                stu[i].print();
                getchar();
                char cc;
                cin>>cc;
                if(cc=='n')
                    continue;
                else if(cc='y')
                {
                    cout<<"请选择修改内容:"<<endl;
                    cout<<"修改日期请按1:\n修改课节请按2:\n修改课程名称请按3:\n修改缺课类型请按4:\n";
                    cin>>x;
                    switch(x)
                    {
                    case 1:
                    {
                        cout<<"请输入正确日期"<<endl;
                        char name[20];
                        cin>>name;
                        strcpy(stu[i].date,name);
                    }
                    break;
                    case 2:
                    {
                        cout<<"请输入正确课节"<<endl;
                        cin>>x;
                        stu[i].ClassX=x;
                    }
                    break;
                    case 3:
                    {
                        cout<<"请输入正确课程名称"<<endl;
                        string name;
                        cin>>name;
                        stu[i].ClassN=name;
                    }
                    break;
                    case 4:
                    {
                        cout<<"请输入正确缺课类型"<<endl;
                        cin>>x;
                        stu[i].ClassL=x;
                    }
                    break;
                    default :
                        cout<<"抱歉,没有该选项。"<<endl;
                    }
                    break;
                    cout<<"输出修改后的学生信息:"<<endl;
                    stu[i].print();
                }
                else
                    cout<<"抱歉,没有该选项。"<<endl;
            }
        }
    }
    else
        cout<<"抱歉,没有该选项。"<<endl;
}
//查询某个学生的缺课情况
void Find(STU stu[])
{
    cout<<"请输入将要查询的学生姓名(1)或者学号(2)"<<endl;
    int x;
    cin>>x;
    if(x==1)
    {
        cout<<"请输入将要查询的学生姓名"<<endl;
        string name;
        cin>>name;
        for(int i=0; i<n; i++)
        {
            if(stu[i].stuN==name)
                stu[i].print();
        }
    }
    else if(x==2)
    {
        cout<<"请输入将要查询的学生学号"<<endl;
        cin>>x;
        for(int i=0; i<n; i++)
        {
            if(stu[i].stuID==x)
                stu[i].print();
        }
    }
    else cout<<"抱歉,没有该选项。"<<endl;
}

//统计旷课学生信息
void chaxun1(STU stu[])
{
    map<string,int> A;
    A.clear();
    for(int s=0; s<n; s++)
    {
        if(stu[s].ClassL==2)
        {
            A[stu[s].stuN]++;
        }
    }
    map<string,int>::iterator it;
    int k=0,ant[N];
    string sn[N];
    for(it=A.begin(); it!=A.end(); it++)
    {
        sn[k]=(*it).first;
        ant[k]=(*it).second;

        k++;
    }
    for(int i=0; i<k-1; i++)
        for(int j=i+1; j<k; j++)
        {
            if(ant[i]<ant[j])
            {
                int temp;
                string ss;
                temp=ant[i];
                ant[i]=ant[j];
                ant[j]=temp;
                ss=sn[i];
                sn[i]=sn[j];
                sn[j]=ss;
            }
        }
    for(int m=0; m<k; m++)
    {
        cout<<"学生姓名 旷课次数"<<endl;
        cout<<sn[m]<<"\t"<<ant[m]<<endl;
    }

}
//统计旷课课程信息
void chaxun2(STU stu[])
{
    map<string,int> A;
    A.clear();
    for(int i=0; i<n; i++)
    {
        if(stu[i].ClassL==2)
        {
            A[stu[i].ClassN]++;
        }
    }
    map<string,int>::iterator it;
    for(it=A.begin(); it!=A.end(); it++)
    {
        cout<<"课程名称 旷课总人次"<<endl;
        cout<<(*it).first<<"\t"<<(*it).second<<endl;
    }
}
int main()
{

    STU stu[N];

    while(1)
    {
        meau();
        cout<<"请输入对应功能序号"<<endl;
        int x;
        cin>>x;
        switch(x)
        {
        case 1:
            Input(stu);
            break;
        case 2:
        {
            if(n==0)
                cout<<"错误,无信息!\n";
            else
                Change(stu);
        }
        break;
        case 3:
        {
            if(n==0)
                cout<<"错误,无信息!\n";
            else
                Find(stu);
        }
        break;
        case 4:
        {
            if(n==0)
                cout<<"错误,无信息!\n";
            else
            {
                cout<<"\n查看学生旷课信息请按1:\n";
                cout<<"\n查看课程旷课信息请按2:\n";
                cin>>x;
                if(x==1)
                    chaxun1(stu);
                else if(x==2)
                    chaxun2(stu);
                else
                    cout<<"抱歉,没有该选项。"<<endl;
            }

        }
        break;
        case 5:
        {
            cout<<"退出该系统。"<<endl;
            return 0;
            break;
        }
        default:
            cout<<"对不起,该项功能不存在."<<endl;

        }

    }
    return 0;
}

你看这个行不行,超过限制了,没法贴上来
https://github.com/Hph1998/Check-work-attendance/blob/master/StudentAttendanceSystem.cpp

github上有很多,上去搜索一下,自己看看需求修改即可


#include<iostream>
#include<cstring>
#include<string>
#include<ctime>
 
 
#include<fstream>
#include<istream>
#include<ostream>
#include<stdio.h>
#include<stdlib.h>
 
 
#define MAX 1000//该系统的容量 可更改
#pragma warning(disable:4996);
using namespace std;
struct student
{
    char S_ID[24];
    char S_name[24];
    char S_sex[24];
    char S_age[24];
    char S_class[24];
};
struct Queke
{
    char Q_data[24];
    char Q_diclass[24];
    char Q_project[24];
    char Q_sort[24];
};
struct Kaoqin
{
    Queke que[MAX];
    student stu[MAX];
    int K_size = 0;
};
 
//定义一个三维数组  这里本来只需要使用一个结构体就可以  但是本人局限于不知道怎么使用结构体数组做函数实参 故此增加了下面一个结构体
struct shuzu
{
    char AA1[9][24];
};
struct Shuzu
{
    shuzu AA[MAX];
};
 
int M;//存储在统计时文件的行数
void menu();
void addstudent(struct Kaoqin* K);
void AddStu(struct Kaoqin* K, char ID[24]);
void showkaoqin(struct Kaoqin* K);
int LookID(struct Kaoqin* K, char ID[24]);
void Addque(struct Kaoqin* K, int i);
void preserve(struct Kaoqin* K);
void readfile(char* filename, struct Shuzu *A1);
void tongji(struct Kaoqin* K, char ID[24]);
int Readfile(char *filename);
 
char filename[1000];
 
int main()
{
    Kaoqin K1;
 
    int Number;
    K1.K_size = 0;
C2:    menu();
    cout << "请输入您想要的功能代号:";
    cin >> Number;
    switch (Number)
    {
    case 1:
    {
    C1:            addstudent(&K1);
        string t;
        cout << "是否继续添加学生:1 :是;    任意键:否" << endl;
        cout << "请输入您的选择:";
        cin >> t;
        if (t == "1")
        {
            goto C1;//该循环用于重复添加多个学生的记录
        }
        break;
    }
    case 2:
    {
        string H_K;
        showkaoqin(&K1);
        cout << "输入 1 保留显示,输入任意键退出该显示界面:";
        cin >> H_K;
        if (H_K == "1")
        {
            break;
        }
        else
        {
            system("cls");
            break;
        }
    }
    case 3:
    {
        char ID[24];
        cout << "请输入您想要统计学生缺课信息的学号:";
        cin >> ID;
        tongji(&K1,ID);
        break;
    }
    case 4:
    {
        preserve(&K1);
        break;
    }
    case 5:
        system("cls");
        system("pause");
        break;
    }
    //system("cls");
    cout << "是否需要执行其他操作:1 是;其他任意键 否" << endl;
    string R;
    cin >> R;
    if (R == "1")
    {
        system("cls");//请屏的指令  类比于MATLAB 中的cls
        goto C2;//这个循环是用于循环操作
    }
    else
    {
        system("cls");
        system("pause");
    }
    return 0;
}
 
//菜单函数  即界面显示的函数
void menu()
{
    cout << "******************************************" << endl;
    cout << "**      功能代号\t" << "具体功能\t**" << endl;
    cout << "**                                      **" << endl;
    cout << "**\t  " << 1 << "\t\t" << "添加功能\t**" << endl;
    cout << "**\t  " << 2 << "\t\t" << "显示功能\t**" << endl;
    cout << "**\t  " << 3 << "\t\t" << "统计功能\t**" << endl;
    cout << "**\t  " << 4 << "\t\t" << "保存功能\t**" << endl;
    cout << "**\t  " << 5 << "\t\t" << "退出    \t**" << endl;
    cout << "******************************************" << endl << endl;
}
 
//总的添加函数  可以选择添加学生基础信息还是已有的学生的考勤信息或者未存在的学生的基础信息加上考勤信息
void addstudent(struct Kaoqin* K)
{
    int i;
    cout << "******************************************" << endl;
    cout << "**      功能代号\t" << "具体功能\t**" << endl;
    cout << "**                                      **" << endl;
    cout << "**\t  " << 1 << "\t\t" << "添加学生记录\t**" << endl;
    cout << "**\t  " << 2 << "\t\t" << "添加缺课记录\t**" << endl;
    cout << "******************************************" << endl << endl;
    cout << "请输入您想要添加的类别:";
    cin >> i;
    switch (i)
    {
    case 1:
    {
        int l;
        char ID[24];
        cout << "请输入您所要添加的学生的学号:";
        cin >> ID;
        if (K->K_size == 0)
        {
            AddStu(K, ID);
        }
        else
        {
            l = LookID(K, ID);
            if (l != 10000)
            {
                cout << "该学号信息已经存在,请勿重复添加该学生的基础信息!!!!!" << endl;
                cout << "请按下任意键实现取消添加!!" << endl;
            }
            else
            {
                AddStu(K, ID);
            }
        }
        break;
    }
    case 2:
    {
        int l;
        char ID[24];
        cout << "请输入您想添加缺课记录的学生的学号:";
        cin >> ID;
        //判断结构体是否为空 若为空就不存在寻找是否会出现去寻找是否重复出现学生记录的操作
        if (K->K_size == 0)
        {
            AddStu(K, ID);
            Addque(K, K->K_size);
        }
        else
        {
            l = LookID(K, ID);//判断是否学号是否已经存在  若存在就直接跳输入基础信息,只输入考勤信息;否则就需要先输入基本信息  再输入考勤信息
            if (l == 10000)
            {
                AddStu(K, ID);
                Addque(K, K->K_size - 1);//这里减 1 的原因是 在每一次添加学生的基础信息后就自动给 K->K_size 加了1,以达到假扩容的目的,
            }                            //以便于在此添加学生信息有空间,然而在这里我们输入的考勤信息是本次添加的学生的,若不减去 1 就会把这个
            else                        //考勤信息给到下一个学生
            {
                Addque(K, l);
            }
        }
        break;
    }
    }
}
 
 
 
//添加学生基础信息的函数  即添加学生结构体中的信息
void AddStu(struct Kaoqin* K, char ID[24])
{
    int t;
    if (K->K_size != 0)
    {
        t = LookID(K, ID);
        if (t == 10000)
        {
            strcpy(K->stu[K->K_size].S_ID, ID);
            cout << "请输入您所要新添加的学生的姓名:";
            cin >> K->stu[K->K_size].S_name;
            cout << "请输入您所要新添加的学生的性别:";
            cin >> K->stu[K->K_size].S_sex;
            cout << "请输入您所要新添加的学生的年龄:";
            cin >> K->stu[K->K_size].S_age;
            cout << "请输入您所要新添加的学生的班级信息:";
            cin >> K->stu[K->K_size].S_class;
            K->K_size = K->K_size + 1;
        }
        else
        {
            cout << "该学号信息已经存在,请勿重复添加该学生的基础信息!!!!!" << endl;
            cout << "是否想要添加该学号学生的缺课信息:1  是   任意键    否";
            string i;
            cin >> i;
            if (i == "1")
            {
                Addque(K, t);
            }
            else
            {
                cout << "请按下任意键实现取消添加!!" << endl;
                system("pause");
            }
        }
    }
    else
    {
        strcpy(K->stu[K->K_size].S_ID, ID);
        cout << "请输入您所要新添加的学生的姓名:";
        cin >> K->stu[K->K_size].S_name;
        cout << "请输入您所要新添加的学生的性别:";
        cin >> K->stu[K->K_size].S_sex;
        cout << "请输入您所要新添加的学生的年龄:";
        cin >> K->stu[K->K_size].S_age;
        cout << "请输入您所要新添加的学生的班级信息:";
        cin >> K->stu[K->K_size].S_class;
        K->K_size = K->K_size + 1;
    }
}
 
//添加缺课记录函数
void Addque(struct Kaoqin* K, int i)
{
    cout << "请输入您所要新添加的学号的同学所缺课的日期:";
    cin >> K->que[i].Q_data;
    cout << "请输入您所要新添加的学号的同学所缺的课是第几节课:";
    cin >> K->que[i].Q_diclass;
    cout << "请输入您所要新添加的学号的同学所缺课的课程名称:";
    cin >> K->que[i].Q_project;
    cout << "请输入您所要新添加的学号的同学缺课的类型:(迟到、早退、请假、旷课 )   ";
    cin >> K->que[i].Q_sort;
}
//显示函数
void showkaoqin(struct Kaoqin* K)
{
    int i;
    cout << "\t学号\t姓名\t性别\t年龄\t班级\t缺课日期\t第几节课\t课程名称\t缺课类型\t" << endl;
    for (i = 0; i < K->K_size; i++)
    {
        cout << "\t" << K->stu[i].S_ID << "\t" << K->stu[i].S_name << "\t" << K->stu[i].S_sex << "\t" << K->stu[i].S_age << "\t" << K->stu[i].S_class << "\t" << K->que[i].Q_data << "\t" << K->que[i].Q_diclass << "\t" << K->que[i].Q_project << "\t" << K->que[i].Q_sort << "\t" << endl;
    }
}
//查找函数
int LookID(struct Kaoqin* K, char ID[24])
{
    int i;
    int t = 10000;
    for (i = 0; i <= K->K_size; i++)
    {
        if (K->stu[i].S_ID == ID)
        {
 
            t = i;
            break;
        }
    }
    return t;
}
//保存函数 保存到kaoqin 文件
void preserve(struct Kaoqin* K)
{
    int i;
    for (i = 0; i < K->K_size; i++)
    {
        if (K->que[i].Q_data == "")
        {
            strcpy(K->que[i].Q_data, "无");
            strcpy(K->que[i].Q_diclass, "无");
            strcpy(K->que[i].Q_project, "无");
            strcpy(K->que[i].Q_sort, "无");
        }
    }
    ofstream ofs;
    string number;
    cout << "请输入您想要保存的文件名(请以 .txt 结尾) " << endl;
    cin >> filename;
    ofs.open(filename, ios::out | ios::in | ios::app);
    cout << "您输入的文件名是否在此之前您是否用过: 0 不是   其余键   是" << endl;
    cin >> number;
    //判断文件是否使用过,如果没有使用过就输出表头,没有就不输出,避免重复输出表头
    if (number == "0")
    {
        ofs << "学号\t姓名\t性别\t年龄\t班级\t缺课日期\t第几节课\t课程名称\t缺课类型\t" << endl;
    }
    for (i = 0; i < K->K_size; i++)
    {
        ofs << K->stu[i].S_ID << "\t" << K->stu[i].S_name << "\t" << K->stu[i].S_sex << "\t" << K->stu[i].S_age << "\t" << K->stu[i].S_class << "\t" << K->que[i].Q_data << "\t" << K->que[i].Q_diclass << "\t" << K->que[i].Q_project << "\t" << K->que[i].Q_sort << "\t" << endl;
    }
    ofs.close();
}
 
//统计函数  只能根据学号进行统计  因为学号是唯一可以独立代表学生的信息
void tongji(struct Kaoqin* K, char ID[24])
{
    int i;
    int tong[MAX][4];
    int chidao = 0;
    int zaotui = 0;
    int qingjia = 0;
    int kuangke = 0;
    int m[MAX];
    ofstream ofs;
    string file;
    cout << "请输入您想将统计信息的保存的文件夹名称(请以 .txt 结尾)" << endl;
    cin >> file;
    cout << endl;
    ofs.open(file, ios::out | ios::in | ios::app);
    cout << "您输入的文件名是否在此之前您是否用过:0 不是   其余键   是" << endl;
    string number;
    cin >> number;
    //判断文件是否使用过,如果没有使用过就输出表头,没有就不输出,避免重复输出表头
    if (number == "0")
    {
        ofs << "学号         \t姓名         \t性别\t年龄\t班级   \t缺课日期\t第几节课\t课程名称\t迟到次数\t早退次数\t请假次数\t旷课次数" << endl;
    }
 
    cout<<"1   从当前记录中去统计学生的考勤记录   2   从已有文件之中去统计学生的考勤记录 "<<endl;
    int Q;
    cin>>Q;
    cout<<endl<<endl;
    switch(Q)
    {
    case 1:
        {
            int k=0;
            int m[MAX];
            //该循环用于查找学号重复的学生  并且存储他们在结构体中的序号
            for (i = 0; i <K->K_size; i++)
            {
                if (K->stu[i].S_ID==ID)
                {
                    m[k]=i;//存储序号
                    k = k + 1;//数组扩容
                }
            }
           for (i = 0; i <K->K_size; i++)
            {
                if (K->que[m[i]].Q_sort == "迟到")
                {
                    chidao = chidao + 1;
                    tong[m[i]][0] = chidao;
                    tong[m[i]][1] = tong[m[i-1]][1];
                    tong[m[i]][2] = tong[m[i-1]][2];
                    tong[m[i]][3] = tong[m[i-1]][3];
                }
                else if (K->que[i].Q_sort == "早退")
                {
                    zaotui = zaotui + 1;
                    tong[m[i]][1] = zaotui;
                    tong[m[i]][0] = tong[m[i-1]][0];
                    tong[m[i]][2] = tong[m[i-1]][2];
                    tong[m[i]][3] = tong[m[i-1]][3];
                }
                else if (K->que[m[i]].Q_sort == "请假")
                {
                    qingjia = qingjia + 1;
                    tong[m[i]][2] = tong[m[i]][2];
                    tong[m[i]][0] = tong[m[i]][0];
                    tong[m[i]][1] = tong[m[i]][1];
                    tong[m[i]][3] = tong[m[i]][3];
                }
                else if (K->que[i].Q_sort == "旷课")
                {
                    kuangke = kuangke + 1;
                    tong[m[i]][3] = kuangke;
                    tong[m[i]][2] = tong[m[i]][2];
                    tong[m[i]][0] = tong[m[i]][0];
                    tong[m[i]][1] = tong[m[i]][1];
                }
                else
                {
                    tong[m[i]][3] = tong[m[i-1]][3];
                    tong[m[i]][2] = tong[m[i-1]][2];
                    tong[m[i]][0] = tong[m[i-1]][0];
                    tong[m[i]][1] = tong[m[i-1]][1];
                }
            }
        ofs << K->stu[m[k-1]].S_ID << "\t" << K->stu[m[k-1]].S_name << "\t" << K->stu[m[k-1]].S_sex << "\t" << K->stu[m[k-1]].S_age << "\t"
            << K->stu[m[k-1]].S_class << "\t" << K->que[m[k-1]].Q_data << "\t" << K->que[m[k-1]].Q_diclass
            << "\t" << K->que[m[k-1]].Q_project << "\t" << tong[m[k-1]][0] << "\t" << tong[m[k-1]][1] << "\t" << tong[m[k-1]][2] << "\t" << tong[m[k-1]][3] << endl;
        }
    case 2:
        {
            //读文件中的信息并且统计
           char filename2[24];
           cout << "请输入您想要统计的学生信息的来源文件夹(请以 .txt结尾)" << endl;
           cin >> filename2;
           cout << endl;
           Shuzu A1;
           readfile(filename2,&A1);
           int k=0;
           for (i = 1; i <M; i++)
            {
                if (strcmp(A1.AA[i].AA1[0],ID)==0)
                {
                    m[k]=i;
                    k = k + 1;
                }
            }
        char *Sort[24];
        Sort[0]="迟到";
        Sort[1]="早退";
        Sort[2]="请假";
        Sort[3]="旷课";
        for (i = 0; i < k; i++)
        {
            if (strcmp(Sort[0],A1.AA[m[i]].AA1[8])==0)
            {
                chidao = chidao + 1;
                tong[m[i]][0] = chidao;
                tong[m[i]][1] = tong[m[i-1]][1];
                tong[m[i]][2] = tong[m[i-1]][2];
                tong[m[i]][3] = tong[m[i-1]][3];
            }
            else if (strcmp(Sort[1],A1.AA[m[i]].AA1[8])==0)
            {
                zaotui = zaotui + 1;
                tong[m[i]][1] = zaotui;
                tong[m[i]][0] = tong[m[i-1]][0];
                tong[m[i]][2] = tong[m[i-1]][2];
                tong[m[i]][3] = tong[m[i-1]][3];
            }
            else if (strcmp(Sort[2],A1.AA[m[i]].AA1[8])==0)
            {
                qingjia = qingjia + 1;
                tong[m[i]][2] = tong[m[i-1]][2];
                tong[m[i]][0] = tong[m[i-1]][0];
                tong[m[i]][1] = tong[m[i-1]][1];
                tong[m[i]][3] = tong[m[i]][3];
            }
            else if (strcmp(Sort[3],A1.AA[m[i]].AA1[8])==0)
            {
                kuangke = kuangke + 1;
                tong[m[i]][3] = kuangke;
                tong[m[i]][2] = tong[m[i-1]][2];
                tong[m[i]][0] = tong[m[i-1]][0];
                tong[m[i]][1] = tong[m[i-1]][1];
            }
            else
            {
                tong[m[i]][3] = tong[m[i-1]][3];
                tong[m[i]][2] = tong[m[i-1]][2];
                tong[m[i]][0] = tong[m[i-1]][0];
                tong[m[i]][1] = tong[m[i-1]][1];
            }
        }
    //只输出最终结果
    ofs << A1.AA[m[k-1]].AA1[0] << "\t" <<A1.AA[m[k-1]].AA1[1] << "\t" << A1.AA[m[k-1]].AA1[2] << "\t" << A1.AA[m[k-1]].AA1[3]<< "\t"
        << A1.AA[m[k-1]].AA1[4] << "\t" <<A1.AA[m[k-1]].AA1[5]<< "\t" << A1.AA[m[k-1]].AA1[6]
        << "\t" <<A1.AA[m[k-1]].AA1[7]<< "\t" << tong[m[k-1]][0] << "\t" << tong[m[k-1]][1] << "\t" << tong[m[k-1]][2] << "\t" << tong[m[k-1]][3] << endl;
    }
    ofs.close();
    }
}
 
 
//读入存储考勤信息的文件内的信息
void readfile(char* filename, struct Shuzu *A1)
{
    ifstream filename1(filename, ios::in);
    if (!filename1)
    {
        cout << "文件打开出错!!!" << endl;
        exit(1);
    }
    M=Readfile(filename);
    for (int i = 0; i <M; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            filename1 >>A1->AA[i].AA1[j];
        }
    }
    filename1.close();
}
 
 
//计算文件的行数(每一行数据个数一定)
int Readfile(char *filename)
{
    char *buf=(char*)malloc(24);
    ifstream filename1(filename, ios::in);
    if (!filename1)
    {
        cout << "文件打开出错!!!" << endl;
        exit(1);
    }
    FILE *fp;
    fp=fopen(filename,"rb");
    if(fp==NULL)
    {
 
        cout<<"文件打开失败"<<endl;
    }
    int N=0;
    float K;
    while(!feof(fp))
    {
        fscanf(fp,"%s",buf+(N++));
    }
    fclose(fp);
    K=N/9;//该语句表示文件的总的行数为K行   总的数据个数为N个(带了表头),每一行的数据个数为9个
    filename1.close();
    return K;
}