Advertisement
vertc

24-10

Oct 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main () {
  7.     string alfj = "abcedfgihjklmnopqrstuvwxyz";
  8.     int dla = alfj.size();
  9.     string tekst;
  10.     string alfz[dla];
  11.  
  12.     for(int i=1;i<dla;i++) {
  13.         if (alfj[i] < 120) {
  14.             alfz[i] = alfj[i-1]+3;
  15.         }
  16.         else {
  17.             alfz[i] = alfj[i-1]+3-25;
  18.         }
  19.     }
  20.     cout<<"Zaszyfrowany alfabet: ";
  21.     for (int i=0;i<dla;i++) {
  22.         cout<<alfz[i];
  23.     }
  24.    
  25.     cout<<endl<<"Wprowdz tekst do zaszyfrowania: ";
  26.     cin>>tekst;
  27.     int dl = tekst.size();
  28.     string szyfr[dl];
  29.     for (int i=0;i<dl;i++) {
  30.         for (int j=0;j<dla;j++) {
  31.             if(tekst[i] == alfj[j]) {
  32.                 szyfr[i] = alfz[j];
  33.             }
  34.         }
  35.     }
  36.     cout<<endl<<"Zaszyfrowany tekst to: ";
  37.     for (int i=0;i<dl;i++) {
  38.         cout<<szyfr[i];
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement