Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sprawdz(char znak)
- {
- if(znak >= 'a'&& znak <= 'z') return 0;
- if (znak >= 'A' && znak <= 'Z') return 1;
- return 2;
- }
- void szyfruj(int klucz, string &tab)
- {
- if(!(klucz >= -26 && klucz <= 26))
- int pom;
- char a, z;
- for (int i = 0; i < tab.size(); i++)
- {pom = sprawdz (tab[i]);
- if(pom<2)
- if(pom == 0)
- a = 'a', z='z';
- else
- a='A', z='Z';
- if(klucz >= 0)
- if(tab[i] + klucz <= z)
- tab[i] += klucz;
- else tab [i] = tab [i] + klucz - 26;
- else
- if(tab[i]+klucz>=a)
- tab[i]+=klucz;
- else tab[i]=tab[i]+klucz+26;
- }
- }
- }
- int main(){
- string tab;
- int klucz
- int x;
- cout<<"podaj tekst do zaszyfrowania"<<endl;
- cin >>tekst;
- cout<<"podaj wspolczynnik przesuniecia"<<endl;
- cin >> x;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement