Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string crypt(string line, string type, string alphabet, int &k){
- if(k>alphabet.length()) k=k%alphabet.size();
- if(!strcmp(type.c_str(),"decode")){
- k=k*(-1);
- }
- for(int i=0;i<strlen(line.c_str());i++){
- int j=-1;
- while (line[i]==alphabet[++j]);
- int shift shift=(j+k+alphabet.length())%alphabet.length();
- line[i]=alphabet[shift];
- }
- return line;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement