Advertisement
iStrzalka

kmc

May 15th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     string wej, wyj;
  7.     getline(cin, wej); // wej;
  8.  
  9.     string alfabet = "abcdefghijklmnoprstuwxyz";
  10.     cout << alfabet.length();
  11.  
  12.     int n, m;
  13.     cin >> n >> m;
  14.  
  15.     int f;
  16.     for(int i = 0; i < wej.length(); i++)
  17.     {
  18.         if(!isalpha(wej[i]))
  19.         {
  20.             wyj += wej[i];
  21.             continue;
  22.         }
  23.         f = alfabet.find(tolower(wej[i]));
  24.         if(m == 1) f = f + n;
  25.         if(m == 2) f = f - n;
  26.  
  27.         if(f > 24) f = f - alfabet.length();
  28.         if(f < 0) f = f + alfabet.length();
  29.  
  30.         wyj += alfabet[f];
  31.         if(isupper(wej[i])) wyj[i] = toupper(wyj[i]);
  32.     }
  33.     cout << wyj;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement