Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<string>
- #include<vector>
- #include<set>
- #include<iostream>
- #include<fstream>
- #include<algorithm>
- using namespace std;
- #define sc scanf
- #define pr printf
- #define fr first
- #define se second
- #define pb push_back
- #define mp make_pair
- const int MN = 5010;
- const int MM = 5010;
- const int mod = 1000000007;
- int q, f;
- string p_naz, dt, s;
- struct fio{
- string f, i, o;
- bool operator<(fio x)const{
- if(f<x.f)return 1;
- if(f>x.f)return 0;
- if(i<x.i)return 1;
- if(i>x.i)return 0;
- if(o<x.o)return 1;
- return 0;
- }
- };
- struct data{
- fio A;
- string ph, bd, sb;
- bool operator<(data x)const{
- return A<x.A;
- }
- };
- struct data2{
- fio A;
- string ph, bd, sb;
- bool operator<(data2 x)const{
- return bd<x.bd;
- }
- };
- set<data>base;
- set<data>::iterator it;
- set<data2>po_bd;
- set<data2>::iterator it2;
- int main(){
- while(1){
- pr("Viberite nomer operacii\n");
- pr("0. Vyhod\n");
- pr("1. Dobavit studenta\n");
- pr("2. Sohranit vsego spisok v fayl\n");
- pr("3. Otkrit spisok iz faila\n");
- pr("4. Vyvodit dannie studenta po nomeru studbileta\n");
- pr("5. Vyvodit studentov otsartirovannuyu po date rojdeniya\n");
- cin>>q;
- if(q == 0){
- return 0;
- }
- if(q == 1){
- data n;
- data2 n2;
- cout<<"FIO cherez probel: ";
- cin>>n.A.f>>n.A.i>>n.A.o;
- n2.A.i = n.A.i;
- n2.A.f = n.A.f;
- n2.A.o = n.A.o;
- cout<<"Telefon: ";
- cin>>n.ph;
- n2.ph = n.ph;
- cout<<"Data rojdeniya v formate ggggmmdd: ";
- cin>>n.bd;
- n2.bd = n.bd;
- cout<<"nomer studbileta: ";
- cin>>n.sb;
- n2.sb = n.sb;
- base.insert(n);
- po_bd.insert(n2);
- }
- if(q == 2){
- ofstream fout("out.txt");
- for(it = base.begin(); it != base.end(); it++){
- fout<<it->A.f<<" "<<it->A.i<<" "<<it->A.o<<" "<<it->ph<<" "<<it->bd<<" "<<it->sb<<endl;
- }
- fout.close();
- }
- if(q == 3){
- ifstream fin("in.txt");
- while(1){
- data n;
- data2 n2;
- fin>>n.A.f>>n.A.i>>n.A.o>>n.ph>>n.bd>>n.bd>>n.sb;
- if(n.A.f.size() == 0){
- break;
- }
- n2.A.f = n.A.f;
- n2.A.i = n.A.i;
- n2.A.o = n.A.o;
- n2.ph = n.ph;
- n2.sb = n.sb;
- }
- fin.close();
- }
- if(q == 4){
- cout<<"Vvodite nomer studbileta: "<<endl;
- cin>>s;
- for(it = base.begin(); it != base.end(); it++){
- if(it->sb == s){
- break;
- }
- }
- if(it == base.end()){
- cout<<"Takoy student ne sushestvuet"<<endl;
- }
- else {
- cout<<it->A.i<<" "<<it->A.f<<" "<<it->A.o<<" "<<it->ph<<" "<<it->bd<<" "<<it->sb<<endl;
- }
- }
- if(q == 5){
- for(it2 = po_bd.begin(); it2 != po_bd.end(); it2++){
- cout<<it2->A.f<<" "<<it2->A.i<<" "<<it2->A.o<<" "<<it2->ph<<" "<<it2->bd<<" "<<it2->sb<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment