Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3. #include<string>
  4. #include<conio.h>
  5. #include<cstring>
  6. using namespace std ;
  7. class event  
  8. {
  9.     private :
  10.     map <int,string> e ;
  11.     public :
  12.         void add_event()
  13.         {
  14.             string ch ;
  15.             int a ;        
  16.             cout<<"Donner l'annee de l'evenement : " ;
  17.             cin>>a ;
  18.             cout<<"Donner l'evenement : " ;
  19.             cin>>ch;
  20.             e.insert(map<int,string>::value_type(a,ch));
  21.         }
  22.         void afficher ()
  23.         {
  24.             for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
  25.                 std::cout << it->first << " : " << it->second << '\n';    
  26.         }
  27.         void find_event_by_date(int x)
  28.         {
  29.             if(e.empty())
  30.                 cout<<"Empty map \n" ;
  31.             else
  32.             {
  33.                  for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
  34.                      if(it->first==x)
  35.                         {  
  36.                             cout<<x<<" : "<<it->second<<endl ;
  37.                         }
  38.             }
  39.         }
  40.         void modify_event(int x)
  41.         {      
  42.             string ch ;
  43.             if(e.empty())
  44.                 cout<<"Empty map \n" ;
  45.             else
  46.             {
  47.                  for (std::map<int,string>::iterator it=e.begin(); it!=e.end(); ++it)
  48.                      if(it->first==x)
  49.                         {                  
  50.                             cout<<"Donner l'evenement : " ;
  51.                             cin>>it->second ;
  52.                         }
  53.             }
  54.     }
  55.  
  56. };
  57. main()
  58. {
  59.     event a ;
  60.     char x='o';
  61.     int annee;
  62.     while(x == 'o')
  63.     {
  64.         a.add_event() ;    
  65.         cout<<"Voulez vous ajouter un autre evenement ? (o/n)\n";
  66.         x = getch();
  67.     }
  68.     cout<<"La liste des evenemements :\n";
  69.     a.afficher();
  70.     cout<<"Donner l'annee a modifier : "; cin>>annee;
  71.     a.modify_event(annee);
  72.     cout<<"La liste des evenemements :\n";
  73.     a.afficher();
  74.    
  75.      system("PAUSE");
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement