Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- string napis;
- int kod,klucz;
- void SzyfrW(char a)
- {
- if(int(a)+3<=122)
- {
- cout<<char(int(a)+klucz);
- }
- else
- {
- cout<<char(int(a)+klucz-26);
- }
- }
- void SzyfrM(char a)
- {
- if(int(a)+3<=90)
- {
- cout<<char(int(a)+klucz);
- }
- else
- {
- cout<<char(int(a)+klucz-26);
- }
- }
- void rozM(char a)
- {
- if(int(a)-klucz>=97)
- {
- cout<<char(int(a)-klucz);
- }
- else
- {
- cout<<char(int(a)+26-klucz);
- }
- }
- void rozW(char a)
- {
- if(int(a)-klucz>=65)
- {
- cout<<char(int(a)-klucz);
- }
- else
- {
- cout<<char(int(a)+26-klucz);
- }
- }
- void szyfrowanie(char *teskt,int przesu)
- {
- }
- int main()
- {
- cout<<"podaj napis do zaszyfrowania"<<endl;
- getline(cin,napis);
- cout<<"podaj klucz: ";
- cin>>klucz;
- klucz=klucz%26;
- cout<<"1.Rozszyfruj 2. zaszyfruj"<<endl;
- cin>>kod;
- cout<<endl;
- int dl= napis.size();
- int klucze[int(dl)];
- if(kod == 2)
- {
- for(int i=0;i<dl;i++)
- {
- if(int(napis[i])>=65&&int(napis[i])>=90)
- {
- SzyfrW(napis[i]);
- }else if(int(napis[i])==32)
- {
- cout<<" ";
- }else
- {
- SzyfrM(napis[i]);
- }
- }
- }
- if(kod == 1)
- {
- for(int j=0;j<dl;j++)
- {
- if(int(napis[j])>=65&&int(napis[j])<=90)
- {
- rozW(napis[j]);
- }else if(int(napis[j])==32)
- {
- cout<<" ";
- }else
- {
- rozM(napis[j]);
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment