Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- string szyfr(string jawny, string klucz)
- {
- string szyfr = "";
- int j=0;
- for (int i=0; i<jawny.length(); i++)
- {
- if ((int)jawny[i]+((int)klucz[j]-64)>90)
- {
- szyfr=szyfr+(char)((int)jawny[i]+((int)klucz[j]-64)-26);
- }
- else
- {
- szyfr=szyfr+(char)((int)jawny[i]+((int)klucz[j]-64));
- }
- j++;
- if (j>=klucz.length())
- {
- j=0;
- }
- }
- return szyfr;
- }
- int main(int argc, char** argv) {
- string a;
- string b;
- string c;
- ifstream odczyt("tj.txt");
- odczyt>>a;
- ifstream odczyt1("klucze1.txt");
- odczyt1>>b;
- ofstream zapis("wyniki.txt");
- szyfr(a, b);
- while (!odczyt.eof())
- {
- odczyt>>a;
- odczyt1>>b;
- c = szyfr(a, b);
- zapis<<c<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement