Advertisement
ewa_tabor

programik,map,list

May 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include<map>
  3. #include<list>
  4. //słownik polsko-angielski,angielsko-pl
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10.     map <string,string> a;
  11.     string bufor;
  12.     a["szczur"]="rat";
  13.     a["mysz"]="mouse";
  14.    
  15.     cin>>bufor;
  16.     int flaga=0;
  17.     for(map<string,string>::iterator i=a.begin(); i!=a.end(); i++){
  18.         //cout<< i->first <<" "<< i->second << endl;
  19.         if(i->first==bufor){
  20.             cout<<i->second<<endl;
  21.             flaga=1;
  22.         }
  23.         if(i->second==bufor) {
  24.             cout<<i->first<<endl;
  25.             flaga=1;
  26.         }
  27.     }
  28.     if (flaga==0) cout<<"Brak podanego hasla w slowniku"<<endl;
  29.     list<string> b;
  30.     b.push_back("a3");
  31.     b.push_back("a1");
  32.     //b.sort();
  33.     for (list<string>::iterator i = b.begin(); i != b.end(); ++i){
  34.         cout << *i << endl;
  35.     }
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement