//今天先写两个基础数据类
#include
using namespace std;
class Time
{
int year;
int month;
int day;
int hour;
public:
Time(int x,int y,int z,int v):year(x),month(y),day(z),hour(v){}
Time(){}
int getYear(){return year;};
int getMonth(){return month;};
int getDay(){return day;};
int getHour(){return hour;};
bool operator<(const Time&d)const
{
return year!=d.year?year
friend ostream&operator<<(ostream &os, const Time &d);
friend istream&operator>>(istream &in, Time &d);
};
ostream&operator<<(ostream &os,const Time &d)
{
os<
}
istream&operator>>(istream &in,Time &d)
{
in>>d.year;
in>>d.month;
in>>d.day;
in>>d.hour;
/*while(1)
{
in>>d.year;
if(d.year>1900&&d.year<2019)
break;
else cout<<"请重输\n";
}
while(1)
{
in>>d.month;
if(d.month>0&&d.month<13)
break;
else cout<<"请重输\n";
}
while(1)
{
in>>d.day;
if(d.day>0&&d.day<32)
break;
else cout<<"请重输\n";
}
while(1)
{
in>>d.hour;
if(d.hour>0&&d.hour<24)
break;
else cout<<"请重输\n";
}
*/
return in;
}
/*
记录类
1.包含借阅人一部分信息
2.借阅图书序号及少部分信息
3.简易为下面服务的函数及运算符重载;
*/
class Record
{
string name;
int id;
int id1;
int code;
int major;
int classes;
int nowBorrows;
int breaks;
string type;
Time start;
Time end;
bool either;
Time changeEnd;
public:
Record(Time t1,Time t2);
Record(){changeEnd=end;}
Time getStart(){return start;};
Time getEnd(){return end;};
Time setChange(Time t){changeEnd=t;}
int getNo(){return id;};
int getId(){return id1;};
string getType(){return type;};
string getName(){return name;};
friend ostream&operator<<(ostream&os,const Record&r);
friend istream&operator>>(istream&in,Record&r);
};
istream&operator>>(istream&in,Record&r)
{
in>>r.id;
if(r.id==0)return in;
in>>r.id1;
in>>r.type;
in>>r.start;
in>>r.end;
r.changeEnd=r.end;
return in;
}
ostream&operator<<(ostream&os,const Record&r)
{
os<
}
Record::Record(Time t1,Time t2)
{
start=t1;
end=t2;
changeEnd=end;
}
/*
书数据类
1.提供书的信息
2.提供这本书一些人借阅记录查阅
3.可借数量,判断函数为下面操作类服务
*/
class Book//书籍类
{
string name;
string name1;
string press;
int no;
int number;//每类书的总数
int borrow;//借出数量
int left;
vector
int num;
public:
Book(string name1,int no1,string press1,int number1,int num1):name(name1),no(no1),press(press1),number(number1),num(num1){}
Book(){number=0;borrow=0;num=0;}
string getName(){return name;};
string getPress(){return press;};
Record getRecord(int i){return r[i];};
void addBorrowsJ(int n){borrow+=n;}
void addBorrowsH(int n){borrow-=n;};
int getNo(){return no;};
int getNum(){return num;};
void setNum(int i){num+=i;};
void addRecord(Record rr){num++;r.push_back(rr);};
int getNowNumber(){return (number-borrow);}//可借数量
int getNumber(){return number;};
int getBorrows(){return borrow;};
int getLeft(){return left;};
friend ostream&operator<<(ostream&os,const Book&b);
friend istream&operator>>(istream&in,Book&b);
};
istream&operator>>(istream&in,Book&b)
{
in>>b.name;
if(b.name=="E")return in;
in>>b.no>>b.name1>>b.press>>b.number>>b.num;
for(int i=0;i
Record rr;
in>>rr;
b.r.push_back(rr);
}
return in;
}
ostream&operator<<(ostream&os,const Book&b)
{
os<
os<
return os;
}
/*
用户数据类
1.提供大多数数据
2.包含一部分小函数
3.查询函数,显示函数,修改函数,为操作类服务;
4.一部分注释,修改版
*/
class User
{
string name;
string major;
string classes;
int id;
int num;//记录条数
int code;
int borrows;
int nowBorrows;
int canReborrow;
bool breaks;
vector
multimap
multimap
multimap
multimap
vector
vector
multimap
multimap
multimap
multimap
multimap
#include
using namespace std;
class Time
{
public:
Time(int year,int month,int day)
{
this->year=year;
this->month=month;
this->day=day;
}
Time()
{
year=0;
month=0;
day=0;
}
void setTime();
int getYear(){return year;};
int getMonth(){return month;};
int getDay(){return day;};
void show(){cout<
friend istream&operator>>(istream&input,Time &t);
private:
int year;
int month;
int day;
};
ostream&operator<<(ostream&output,Time&t)
{
output<
}
istream&operator>>(istream&input,Time &t)
{
input>>t.year>>t.month>>t.day;
return input;
}
void Time::setTime()
{
cin>>year>>month>>day;
}
class student
{
public:
student(int id,string name,Time t,string lesson,int node,string type)
{
//后期先写time类,不用int time;
this->id=id;
this->name=name;
this->t=t;
this->lesson=lesson;
this->node=node;
this->type=type;
}
student()
{//不写初始化的t;
id=0;
name="";
lesson="";
node=0;
type="";
}
private:
Time t;
int id;
string name;
string lesson;
int node;
string type;
};
class operate//操作类
{
private:
vector
student st;
Time t;
public:
operate(){}
operate(int id,string name,Time t,string lesson,int node,string type):st(id,name,t,lesson,node,type){}
void input();//输入
void inputs();
void output();//输出
void query();//查询
void show();//输出所有信息
void change();//修改
void name();
void lesson();
};
void operate::show()
{
cout<<"学生后勤管理系统"<
void operate::inputs()
{
int n;
cin>>n;
switch(n)
{
case 1://输入数据
system("CLS");
input();
system("pause");
break;
/* case 2:
system("CLS");
xiugai(myList);
system("pause");
break;
case 3:
system("CLS");
chaxun(myList);
system("pause");
break;
case 4:
system("CLS");
tongji1(myList);
system("pause");
break;
case 5:
system("CLS");
tongji2(myList);
system("pause");
break;
case 6:
system("CLS");
output(myList);
system("pause");
case 7:
system("CLS");
break;*/
default:
system("CLS");
break;
}
}
void operate::input()
{
string name;
string lesson_name;
int id;
string type;
int jieci;
cout<<"请输入学号: "<
cout<<"请输入姓名: "<
cout<<"请输入时间: "<
cout<<"请输入课程: "<
cout<<"请输入节次: "<
cout<<"请输入缺课类型:(1.迟到,2,旷课,3.请假) "<
student stu(id,name,t,lesson_name,jieci,type);
p.push_back(stu);
cout<<"需要继续输入学生信息,输入1,否输入0"<
cin>>x;
if(x==1)
{
show();
inputs();
}
}
int main()
{
operate op;//无参不加括号
op.show();
op.inputs();
}
#include
using namespace std;
class Static
{
static int num;
public:
static int getNum(){return num;};
static void setNum(int n){num=n;};
};
int Static::num=0;
class Data
{
int year;
int month;
int day;
public:
Data(int x,int y,int z):year(x),month(y),day(z){}
Data(){}
int getYear(){return year;};
int getMonth(){return month;};
int getDay(){return day;};
bool operator<(const Data&d)const
{
return year!=d.year?year
friend ostream&operator<<(ostream &os, const Data &d);
friend istream&operator>>(istream &in, Data &d);
};
ostream&operator<<(ostream &os,const Data &d)
{
os<
}
istream&operator>>(istream &in,Data &d)
{
in>>d.year;
while(1)
{
if(d.year>1000&&d.year<3000)
break;
else
{
cout<<"请重试";
in>>d.year;
}
}
in>>d.month;
while(1)
{
if(d.month>0&&d.month<13)
break;
else
{
cout<<"请重试";
in>>d.month;
}
}
in>>d.day;
while(1)
{
if(d.day>0&&d.day<32)
break;
else
{
cout<<"请重试";
in>>d.day;
}
}
return in;
}
class Record
{
string str;
Data start;
Data end;
public:
Record(string sr,Data s,Data e):str(sr),start(s),end(e){}
Record(){}
Data getDataS(){return start;};
Data getDataE(){return end;};
string getStr(){return str;};
friend ostream&operator<<(ostream&os,const Record&r);
friend istream&operator>>(istream&in,Record &r);
};
ostream&operator<<(ostream&os,const Record&r)
{
os<
}
istream&operator>>(istream&in,Record &r)
{
in>>r.str;
if(r.str=="end")return in;
in>>r.start>>r.end;
return in;
}
struct cmp1
{
string str;
cmp1(string s){str=s;};
bool operator()(Record &r)
{
return (r.getStr().find(str)!=string::npos);
}
};
struct cmp2
{
int m;
cmp2(int num){m=num;};
bool operator()(Record &r)
{
return (r.getDataS().getMonth()
};
class Demos
{
private:
vector
vector
multimap
multimap
multimapm2;
multimap::iterator m2p;
public:
/*Demos()
{load();}
~Demos()
{
save();
}*/
Demos(){}
void Plus();//增加多条
void dd(Record r1);
void load();//读文件
void save();
int search1(string s);
int search2(Data d);
void deleteStr(string s);
void display();
void search3(string s);
void search4(int m);
}
void Demos::dd(Record r1)
{
cout<<"ADD"<
int i=v.size();
m1.insert(make_pair(r1.getStr(),i-1));
m2.insert(make_pair(r1.getDataS(),i-1));
}
void Demos::Plus()
{
cout<<"ADD"<
while(1)
{
cin>>r;
if(r.getStr()=="end")break;
v.push_back(r);
int i=v.size();
m1.insert(make_pair(r.getStr(),i-1));
m2.insert(make_pair(r.getDataS(),i-1));
}
}
void Demos::display()
{
cout<
{
cout<<*it;
}
}
int Demos::search1(string s)
{
m1p=m1.find(s);
if(m1p!=m1.end())
{
cout<<"found"<
}
else return -1;
}
int Demos::search2(Data d)
{
m2p=m2.find(d);
if(m2p!=m2.end())
{
cout<<"found";
return m2p->second;
}
else return -1;
}
void Demos::search3(string s)
{
it=find_if(v.begin(),v.end(),cmp1(s));
while(it!=v.end())
{
cout<<"found";
cout<
}
}
void Demos::search4(int m)
{
it=find_if(v.begin(),v.end(),cmp2(m));
while(it!=v.end())
{
cout<<"found";
cout<
}
}
void Demos::load()
{
Record r;
int i;
ifstream infile("d:\\Demo.txt",ios::in);
if(!infile)
return;
v.clear();
m1.clear();
m2.clear();
i=0;
while(infile>>r)
{
v.push_back(r);
m1.insert(make_pair(r.getStr(),i-1));
m2.insert(make_pair(r.getDataS(),i-1));
i++;
}
infile.close();
}
void Demos::save()
{
ofstream outfile("d:\\Demo.txt",ios::out);
if(!outfile)
{
return;
}
for(it=v.begin();it!=v.end();it++)
{
outfile<<*it;
}
outfile.close();
}
int main()
{
Data d;
cin>>d;
cout<
#include
using namespace std;
class Time//时间类,包含年月日时
{
int year;
int month;
int day;
int hour;
public:
Time(int x,int y,int z,int v):year(x),month(y),day(z),hour(v){}
Time(){}
int getYear(){return year;};
int getMonth(){return month;};
int getDay(){return day;};
int getHour(){return hour;};
bool operator<(const Time&d)const
{
return year!=d.year?year
friend ostream&operator<<(ostream &os, const Time &d);
friend istream&operator>>(istream &in, Time &d);
};
ostream&operator<<(ostream &os,const Time &d)
{
os<
}
istream&operator>>(istream &in,Time &d)
{
in>>d.year;
while(1)
{
if(d.year>1000&&d.year<3000)
break;
else
{
cout<<"请输入正确时间"<
}
}
in>>d.month;
while(1)
{
if(d.month>0&&d.month<13)
break;
else
{
cout<<"请输入正确时间"<
}
}
in>>d.day;
while(1)
{
if(d.day>0&&d.day<32)
break;
else
{
cout<<"请输入正确时间"<
}
}
in>>d.hour;
while(1)
{
if(d.hour>-1&&d.hour<25)
break;
else
{
cout<<"请输入正确时间"<
}
}
return in;
}
class Book//书籍类
{
string name;
string press;
int no;
int number;
int borrow;
int left;
public:
Book(string name1,int no1,string press1,int number1):name(name1),no(no1),press(press1),number(number1){}
Book(){number=0;borrow=0;}
string getName(){return name;};
string getPress(){return press;};
int getNo(){return no;};
int getNumber(){return number;};
int getLeft(){return left;};
friend ostream&operator<<(ostream&os,const Book&b);
friend istream&operator>>(istream&in,Book&b);
};
istream&operator>>(istream&in,Book&b)
{
in>>b.name>>b.no>>b.press>>b.number;
return in;
}
ostream&operator<<(ostream&os,const Book&b)
{
os<
}
class Record//一条记录对应一个人一本书
{
int id;
string name;
Time start;
Time end;
Book b;
bool either;
Time changeEnd;
public:
Record(int id1,Time t1,Time t2,Book B1,bool e);
Record(){}
int getId(){return id;};
string getName(){return name;};
Time getStart(){return start;};
Time getEnd(){return end;};
friend ostream&operator<<(ostream&os,const Record&r);
friend istream&operator>>(istream&in,Record&r);
}; }
istream&operator>>(istream&in,Record&r)
{
in>>r.id>>r.name>>r.start>>r.end>>r.b;
in>>r.either;
if(r.either==1)
{
cin>>r.changeEnd;
in>>r.changeEnd;
}
return in;
}
ostream&operator<<(ostream&os,const Record&r)
{
os<<"学号 姓名"<
}
Record::Record(int id1,Time t1,Time t2,Book b1,bool e)
{
id=id1;
start=t1;
end=t2;
b=b1;
either=e;
end=changeEnd;
}
class User
{
string name;
string classes;
int id;
int borrows;
int nowBorrows;
bool breaks;
vector
vector
multimap
multimap
multimap
multimap
public:
User(){}
};
int main()
{
/*Time t;
cin>>t;
cout<
cin>>b;
cout< Record r;
cin>>r;
cout<