SHARE
TWEET

Untitled

a guest Oct 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int checkIndex(char* T, char s) {
  7.     for(int i=0;i<26;i++) {
  8.         if(T[i] == s) {
  9.             return i;
  10.         }
  11.     }
  12.    
  13. }
  14.  
  15. main() {
  16.     char T[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  17.     int key = 5;
  18.     string s;
  19.     cout<<"Podaj slowo: ";
  20.     cin>>s;
  21.     string a;
  22.     for(int i=0;i<s.length();i++) {
  23.         char g = s[i];
  24.         int index = checkIndex(T,g)+key;
  25.         if(index>(26-key)) {
  26.             index = index-26;
  27.         }
  28.         a += T[index];
  29.     }
  30.     cout<<a;
  31.    
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top