Facebook
From Soft Lizard, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 246
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4. using namespace std;
  5. main (){
  6.         string T;
  7.         int a;
  8.         cout<<"Wprowadz tekst (bez spacji) do zaszyfrowania: ";
  9.         cin>>T;
  10.         cout<<"O ile ma byc przesuniety tekst do zaszyfrowania: ";
  11.         cin>>a;
  12.         for(int i=0; i<=T.length(); i++){
  13.         if(T[i]>=65 && T[i]<=90-a)
  14.                 T[i]=int(T[i])+a;
  15.         else if(T[i]>=91-a && T[i]<=90)
  16.                 T[i]=int(T[i])-26+a;
  17.         else if(T[i]>=97 && T[i]<=122-a)
  18.                 T[i]=int(T[i])+a;
  19.         else if(T[i]>=123-a && T[i]<=122)
  20.                 T[i]=int(T[i])-26+a;
  21.         }
  22.         cout<<"\nTekst zostal zaszyfrowany:\n";
  23.         for(int i=0; i<=T.length(); i++){
  24.                 cout<<T[i];
  25.         }      
  26.  
  27.         system("pause");
  28.         return 0;
  29. }