modlicha

zad mat 4 fstream

Oct 25th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. ifstream a,b;
  8. ofstream c;
  9. string x;
  10. string y;
  11.  
  12. int main()
  13. {
  14. a.open("sz.txt");
  15. b.open("klucze2.txt");
  16. c.open("wynik4b.txt");
  17.  
  18. while (a >> x)
  19. {
  20. b >> y;
  21.  
  22. while (x.size() > y.size())
  23. {
  24. y = y + y;
  25. }
  26.  
  27. for(int i = 0; i < x.size(); i++)
  28. {
  29. int kod = int(x[i]) + int(y[i]) - 64;
  30.  
  31. if(kod > 90)
  32. {
  33. kod -= 26;
  34. }
  35. c << char(kod);
  36.  
  37. }
  38. c << endl;
  39. }
  40.  
  41. a.close();
  42. b.close();
  43. c.close();
  44.  
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment