Advertisement
Guest User

Shift

a guest
May 1st, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string parola;
  6. int shift;
  7. char ritorno;
  8. int main()
  9. {
  10.     cout<<"Inserisci la parola : ";
  11.     cin>>parola;
  12.     cout<<"Inserisci il valore di shift : ";
  13.     cin>>shift;
  14.    
  15.    
  16.     for(int i=0; i<=parola.length(); i++)
  17.     /* parola.lenght() indica il N° di caratteri
  18.     da cui è composta la variabile parola, inserita da tastiera */
  19.     {
  20.         parola[i]=parola[i]+shift;
  21.         if(parola[i]+shift>122)
  22.         ritorno=(parola[i]+shift)/26;
  23.         parola[i]=(parola[i]+shift)-(26*(ritorno-3))-1;
  24.        
  25.     }
  26.     cout<<parola;
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement