Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7.  
  8. class cezar
  9. {
  10. int klucz;
  11. string dane;
  12. string szyfr;
  13.  
  14. public:
  15. cezar(string,int);
  16.  
  17. void szyfruj();
  18.  
  19. string zaszyfrowany();
  20.  
  21. };
  22. cezar::cezar(string dane1, int klucz1)
  23. {
  24. dane=dane1;
  25. klucz=klucz1;
  26.  
  27. }
  28.  
  29. void cezar::szyfruj(){
  30. for(int i=0;i<dane.length();i++){
  31.  
  32. szyfr+=dane[i]+klucz;
  33. }
  34.  
  35. }
  36.  
  37. string cezar::zaszyfrowany(){
  38. return szyfr;
  39. }
  40.  
  41. int main(int argc, char** argv) {
  42.  
  43.  
  44.  
  45. string liczba;
  46. fstream plik;
  47. ofstream plik1;
  48. plik1.open("a.txt");
  49. plik.open("b.txt", ios::in);
  50. if(plik.good())
  51. while(!plik.eof())
  52. {
  53. plik>>liczba;
  54. cout<<liczba;
  55. cout<<endl;
  56. cezar wyraz(liczba,2);
  57. wyraz.szyfruj();
  58. cout<<wyraz.zaszyfrowany();
  59. plik1<<wyraz.zaszyfrowany()<< " ";
  60.  
  61. }
  62. plik.close();
  63. system ("pause >nul");
  64. plik1.close();
  65. return 0;
  66.  
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement