SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int klucz,k,kk=1;
  6.     string slowo;
  7.     cout<<"Podaj slowo do zaszyfrowania: ";
  8.     cin>>slowo;
  9.     cout<<"Podaj klucz: ";
  10.     cin>>klucz;
  11.     char sz[klucz][slowo.size()];
  12.     for (int i=0;i<klucz;i++)
  13.         for (int j=0;j<slowo.size(); j++)
  14.            sz[i][j]=' ';
  15.     for (int j=0;j<slowo.size();j++)
  16.     {
  17.         sz[k][j]=slowo[j];
  18.         k+=kk;
  19.         if(k>=klucz-1 || k==0) kk=kk*-1;
  20.     }
  21.     for (int i=0;i<klucz;i++)
  22.     {
  23.         for (int j=0;j<slowo.size();j++)
  24.         {
  25.             cout<<sz[i][j];
  26.         }
  27.         cout<<"\n";
  28.     }
  29.     for (int i=0;i<klucz;i++)
  30.     {
  31.         for (int j=0;j<slowo.size();j++)
  32.         {
  33.             if(sz[i][j]!=' ') cout<<sz[i][j];
  34.         }
  35.     }
  36. }
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
 
Top