Facebook
From lomba, 1 Month ago, written in C++.
This paste is a reply to ttt from itu - view diff
Embed
Download Paste or View Raw
Hits: 197
  1.  
  2. #include<bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char lw_ar[26]= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  9.     char up_ar[26]= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  10.     cout<<"Enter your encrypted text : ";
  11.     string s;
  12.     cin>>s;
  13.     cout<<"Enter your key : ";
  14.     int key;
  15.     cin>>key;
  16.     string decyrp="";
  17.     for(int i=0;i<s.size();i++){
  18.         if(s[i]>='a')
  19.         {
  20.         int tmp=((s[i]-'a')-key+26)&;
  21.         decyrp+=lw_ar[tmp];
  22.         }
  23.         else{
  24.         int tmp=((s[i]-'A')-key+26)&;
  25.         decyrp+=up_ar[tmp];
  26.         }
  27.     }
  28.     cout<<"Your decrypted cipher is : "<<decyrp<<endl;
  29.  
  30. }
  31.