Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string Zaszyfrowanie(string);
- string Odszyfrowanie(string);
- const int ile = 3;
- int main()
- {
- string slowo;
- cout << "podaj slowo do zaszyfrowania: ";
- cin >> slowo;
- cin.ignore();
- cout << "zaszyfrowane dane: " << Zaszyfrowanie(slowo) << "\n";
- cout << "A odszyfrowane to: " << Odszyfrowanie(Zaszyfrowanie(slowo))
- return 0;
- }
- string Zaszyfrowanie(string slowo)
- {
- int t;
- for(int i = 0; i < slowo.length(); i++)
- {
- t = slowo[i] + ile;
- if(t <65)
- slowo[i] +=(26 +ile);
- else if (t > 90)
- slowo[i] -=(26-ile);
- else
- slowo[i] +=ile;
- }
- return slowo;
- }
- string Odszyfrowanie(string slowo)
- {
- int t;
- for(int i = 0; i < slowo.length(); i++)
- {
- t = slowo[i]- ile;
- if(t <65)
- slowo[i]+=(26 -ile);
- else if (t > 90)
- slowo[i] -=(26+ile);
- else
- slowo[i] +=ile;
- }
- return slowo;
- }
Advertisement
Add Comment
Please, Sign In to add comment