Advertisement
polpoteu

COO polskie cpp

Nov 7th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. string szyfr(string jawny, string klucz)
  5. {
  6. string szyfr = "";
  7. int j=0;
  8. for (int i=0; i<jawny.length(); i++)
  9. {
  10. if ((int)jawny[i]+((int)klucz[j]-64)>90)
  11. {
  12. szyfr=szyfr+(char)((int)jawny[i]+((int)klucz[j]-64)-26);
  13. }
  14. else
  15. {
  16. szyfr=szyfr+(char)((int)jawny[i]+((int)klucz[j]-64));
  17. }
  18. j++;
  19. if (j>=klucz.length())
  20. {
  21. j=0;
  22. }
  23. }
  24. return szyfr;
  25. }
  26. int main(int argc, char** argv) {
  27. string a;
  28. string b;
  29. string c;
  30.  
  31. ifstream odczyt("tj.txt");
  32. odczyt>>a;
  33. ifstream odczyt1("klucze1.txt");
  34. odczyt1>>b;
  35. ofstream zapis("wyniki.txt");
  36. szyfr(a, b);
  37. while (!odczyt.eof())
  38. {
  39. odczyt>>a;
  40. odczyt1>>b;
  41. c = szyfr(a, b);
  42. zapis<<c<<endl;
  43. }
  44.  
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement