#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<conio.h>
using namespace std;
struct record{
string data;string shu;string cls;string name;string type;
};
struct ju{
string data;string name;
};
struct record0{
string data;string cls;
};
struct record1{
string name;int jie;
};
struct record2{
string cls;int ci;
};
istream& read(istream& is,record& s)
{
is>>s.data>>s.shu>>s.cls>>s.name>>s.type;
return is;
}
bool comparet(const record& x, const record& y)
{
return x.type < y.type;
}
bool compared(const ju& x, const ju& y)
{
return x.data < y.data;
}
bool compare(const record& x, const record& y)
{
return x.data < y.data;
}
bool compare0(const record0& x, const record0& y)
{
return x.data < y.data;
}
bool compare1(const record& x, const record& y)
{
return x.shu < y.shu;
}
bool compare2(const record& x, const record& y)
{
return x.name < y.name;
}
bool compare3(const record1& x, const record1& y)
{
return x.name < y.name;
}
bool compare4(const record1& x, const record1& y)
{
return x.jie > y.jie;
}
bool compare5(const record2& x, const record2& y)
{
return x.cls < y.cls;
}
bool compare6(const record2& x, const record2& y)
{
return x.ci > y.ci;
}
void biao()
{
cout<<"┌──────────────────────────┐\n"
<<"│ 学生考勤管理系统 │\n"
<<"├──────────────────────────┤\n"
<<"│ │\n"
<<"│1、请输入考勤记录。 │\n"
<<"│ │\n"
<<"│2、修改任意缺课记录。 │\n"
<<"│ │\n"
<<"│3、查询某个学生的缺课情况(查询结果按日期升序排序, │\n"
<<"│ 同一天内则按时间升序排序)。 │\n"
<<"│ │\n"
<<"│4、统计某段时间内(以天为单位)旷课学生姓名及旷课 │\n"
<<"│ 节数(查询结果先按旷课节数降序排序,旷课节数相同 │\n"
<<"│ 的学生再按姓名升序排序)。 │\n"
<<"│ │\n"
<<"│5、统计某段时间内(以天为单位)有学生旷课的课程及旷 │\n"
<<"│ 课人次(查询结果按旷课人次由多到少排序,旷课人次 │\n"
<<"│ 相同的课程按课程名称升序排序; │\n"
<<"│ │\n"
<<"│6、退出 │\n"
<<"│ │\n"
<<"└──────────────────────────┘\n";
}
main()
{
biao();
int z,y,i,t,c,h,t1,t2,x1,x2,b;
string ming,xxxx,d1,d2,na,na1,data0,cl,cl1,data,cls,y1,y2,y3,y4,y5;
vector<record> students;
vector<ju> students0;
vector<record0> students1;
vector<record1> one;
vector<record2> two;
record record;
printf("请先输入: 1\n");
cin>>z;
if(z==1)
{
cout<<"请输入考勤记录"<<endl;
while(read(cin,record))
{
students.push_back(record);
}
cin.clear();
printf("记录已经输入,请选择需要操作的选项: \n");
cin>>y;
while(y!=0)
{
if(y==2)
{
cout<<"请输入要修改的考勤记录"<<endl;
cin>>y1>>y2>>y3>>y4>>y5;
for(i=0;i<students.size();i++)
{
if(students[i].data==y1&&
students[i].shu==y2&&
students[i].cls==y3&&
students[i].name==y4&&
students[i].type==y5)
t=i;
}
cout<<"请选择要修改的部分:"<<endl;
cout<<"21是缺课日期,22是第几节课,23是课程名,24是学生姓名,25是缺课类型"<<endl;
cin>>c;
while(c!=0)
{
if(c==21)
{
cout<<"请输入改正后的内容"<<endl;
cin>>xxxx;
students[t].data=xxxx;
cout<<"请再次选择要修改的部分或输入0结束:"<<endl;
}
else if(c==22)
{
cout<<"请输入改正后的内容"<<endl;
cin>>xxxx;
students[t].shu=xxxx;
cout<<"请再次选择要修改的部分或输入0结束:"<<endl;
}
else if(c==23)
{
cout<<"请输入改正后的内容"<<endl;
cin>>xxxx;
students[t].cls=xxxx;
cout<<"请再次选择要修改的部分或输入0结束:"<<endl;
}
else if(c==24)
{
cout<<"请输入改正后的内容"<<endl;
cin>>xxxx;
students[t].name=xxxx;
cout<<"请再次选择要修改的部分或输入0结束:"<<endl;
}
else if(c==25)
{
cout<<"请输入改正后的内容"<<endl;
cin>>xxxx;
students[t].type=xxxx;
cout<<"请再次选择要修改的部分或输入0结束:"<<endl;
}
cin>>c;
}
for(i=0;i<students.size();i++)
{
cout<<students[i].data<<" "<<students[i].shu<<" "<<students[i].cls<<" "
<<students[i].name<<" "<<students[i].type<<endl;
}
printf("记录已经输入,请再选择需要操作的选项: \n");
}
if(y==3)
{
sort(students.begin(),students.end(),compare1);
sort(students.begin(),students.end(),compare);
cout<<"请输入要查询的学生的名字"<<endl;
cin>>ming;
for(i=0;i<students.size();i++)
{
if(students[i].name==ming)
cout<<students[i].data<<" "<<students[i].shu<<" "<<students[i].cls<<" "
<<students[i].name<<" "<<students[i].type<<endl;
}
printf("结果已经输出,请再选择需要操作的选项: \n");
}
if(y==4)
{
sort(students.begin(),students.end(),comparet);
x1=0;
x2=students.size()-1;
while(students[x1].type!="旷课")
++x1;
while(students[x2].type!="旷课")
--x2;
students0.resize(x2-x1+1);
for(i=x1,b=0;i<=x2;i++,b++)
{
data0=students[i].data;
ming=students[i].name;
students0[b].data=data0;
students0[b].name=ming;
}
sort(students0.begin(),students0.end(),compared);
cout<<"请输入起始日期"<<endl;
cin>>d1;
cout<<"请输入终止日期"<<endl;
cin>>d2;
t1=0;
t2=students0.size()-1;
while(students0[t1].data<d1)
++t1;
while(students0[t2].data>d2)
--t2;
one.resize(t2-t1+1);
for(i=t1,b=0;i<t2-t1+1;i++,b++)
{
na=students0[i].name;
one[b].name=na;
for(c=t1,h=0;c<t2-t1+1;c++)
{
if(na==students0[c].name)
h++;
}
one[b].jie=2*h;
}
cout<<"按旷课节数和旷课人名字排列"<<endl;
sort(one.begin(),one.end(),compare3);
sort(one.begin(),one.end(),compare4);
i=1;na1=one[0].name;
cout<<one[0].jie<<" "<<na1<<endl;
while(i<one.size())
{
while(one[i].name!=na1)
{
na1=one[i].name;
cout<<one[i].jie<<" "<<na1<<endl;
}
++i;
}
cout<<"结果已经输出,请再选择需要操作的选项:"<<endl;
}
if(y==5)
{
sort(students.begin(),students.en