Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- #include<string>
- #include<conio.h>
- #include<cstring>
- using namespace std ;
- class event
- {
- private :
- map <int,string> e ;
- public :
- void add_event()
- {
- string ch ;
- int a , test= 0;
- cout<<"Donner l'annee de l'evenement : " ;
- cin>>a ;
- cout<<"Donner l'evenement : " ;
- cin>>ch;
- for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
- if(it->first==a)
- {
- it->second = it->second + ch + "#" ;
- test = 1;
- }
- if(test == 0)
- {
- e.insert(map<int,string>::value_type(a,ch+"#"));
- }
- }
- void afficher ()
- {
- for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
- std::cout << it->first << " : " << it->second << '\n';
- }
- void find_event_by_date(int x)
- {
- if(e.empty())
- cout<<"Empty map \n" ;
- else
- {
- for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
- if(it->first==x)
- {
- string subevent ="";
- for(int i = 0; i < (it->second).length(); i++)
- {
- if(it->second.at(i) != '#')
- {
- subevent = subevent + it->second.at(i);
- }
- else
- {
- cout<<x<<" : "<<subevent<<"\n" ;
- subevent = "";
- }
- }
- }
- }
- }
- void modify_event(int x)
- {
- string ch ;
- if(e.empty())
- cout<<"Empty map \n" ;
- else
- {
- for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
- if(it->first==x)
- {
- cout<<"Donner l'evenement : " ;
- cin>>it->second ;
- }
- }
- }
- };
- main()
- {
- event a ;
- char x='o';
- int annee;
- while(x == 'o')
- {
- a.add_event() ;
- cout<<"Voulez vous ajouter un autre evenement ? (o/n)\n";
- x = getch();
- }
- cout<<"La liste des evenemements :\n";
- a.afficher();
- //cout<<"Donner l'annee a modifier : "; cin>>annee;
- //a.modify_event(annee);
- //cout<<"La liste des evenemements :\n";
- //a.afficher();
- a.find_event_by_date(2003);
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement