Advertisement
ItsMeLucifer

SzyfryHarcerskie C++

May 8th, 2019
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <string>
  4. using namespace std;
  5. void kod(int ilosc,string tab[],string wej){
  6. for (int i=0;i<ilosc;i++){
  7.         wej.at(i)=toupper(wej.at(i));
  8.         for(int j=0;j<5;j++){
  9.             if (wej.at(i)==tab[j].at(0)){
  10.                 wej.at(i)=tab[j].at(1);
  11.             }
  12.             if (wej.at(i)==tab[j].at(1)){
  13.                 wej.at(i)=tab[j].at(0);
  14.             }
  15.         }
  16.     }
  17.     cout<<wej;
  18. }
  19. int main()
  20. {
  21.     string wej,literka,wiekszy0,wiekszy1,mniejszy0,mniejszy1;
  22.     string str;
  23.     string ile;
  24.     string tab[]={"GA","DE","RY","PO","LU","KI"};
  25.     string tab1[]={"PO","LI","TY","KA","RE","NU"};
  26.     string tab2[]={"KA","CE","MI","NU","TO","WY"};
  27.     cout<<"Wybierz jeden z kodow:\n1:GA-DE-RY-PO-LU-KI\n2:PO-LI-TY-KA-RE-NU\n3:KA-CE-MI-NU-TO-WY"<<endl;
  28.     //do{
  29.     getline(cin,ile);
  30.     //}while(ile!="1" || ile!="2"||ile!="3");
  31.     cout<<"Podaj ciag wejsciowy:"<<endl;
  32.     getline(cin,wej);
  33.     int ilosc = wej.size();
  34.  
  35.     if(ile=="1"){
  36.     kod(ilosc,tab,wej);
  37.     }
  38.     if(ile=="2"){
  39.     kod(ilosc,tab1,wej);
  40.     }
  41.     if(ile=="3"){
  42.     kod(ilosc,tab2,wej);
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement