Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int klucz,k,kk=1;
- string slowo;
- cout<<"Podaj slowo do zaszyfrowania: ";
- cin>>slowo;
- cout<<"Podaj klucz: ";
- cin>>klucz;
- char sz[klucz][slowo.size()];
- for (int i=0;i<klucz;i++)
- for (int j=0;j<slowo.size(); j++)
- sz[i][j]=' ';
- for (int j=0;j<slowo.size();j++)
- {
- sz[k][j]=slowo[j];
- k+=kk;
- if(k>=klucz-1 || k==0) kk=kk*-1;
- }
- for (int i=0;i<klucz;i++)
- {
- for (int j=0;j<slowo.size();j++)
- {
- cout<<sz[i][j];
- }
- cout<<"\n";
- }
- for (int i=0;i<klucz;i++)
- {
- for (int j=0;j<slowo.size();j++)
- {
- if(sz[i][j]!=' ') cout<<sz[i][j];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement