Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Cipher(char *_Origin, int _Key);
- void main()
- {
- Cipher("CAT", 3);
- Cipher("CABBAGE", 3);
- Cipher("TEST", 8);
- Cipher("HELLO, WORLD!", 5);
- }
- void Cipher(char * _Origin, int _Key)
- {
- int Size = 0;
- do Size++;
- while (*(_Origin + Size) != '\0');
- char *Ciphered = new char[Size+1];
- for (int i = 0;i < Size;i++)
- {
- if (((int)*(_Origin + i)) < 65 || ((int)*(_Origin + i)) > 90)
- {
- Ciphered[i] = (int)*(_Origin + i);
- }
- else if (((int)*(_Origin + i)) + _Key > 90)
- {
- Ciphered[i] = ((int)*(_Origin + i)) + _Key - 26;
- }
- else
- {
- Ciphered[i] = ((int)*(_Origin + i)) + _Key;
- }
- }
- Ciphered[Size] = '\0';
- cout << Ciphered << endl;
- delete[] Ciphered;
- }
Add Comment
Please, Sign In to add comment