MeehoweCK

Untitled

May 15th, 2020
1,237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string plik_in, plik_out;
  10.     cout << "Plik wejsciowy: ";
  11.     cin >> plik_in;
  12.     cout << "Plik wyjsciowy: ";
  13.     cin >> plik_out;
  14.  
  15.     ifstream input;
  16.     ofstream output;
  17.     input.open(plik_in.c_str());
  18.     output.open(plik_out.c_str());
  19.  
  20.     if(input.fail() || output.fail())
  21.     {
  22.         cout << "blad pliku" << endl;
  23.         return 0;
  24.     }
  25.  
  26.     int n = 5;
  27.     char znak;
  28.  
  29.     while(!input.eof())
  30.     {
  31.         input.get(znak);
  32.         if(isalpha(znak))
  33.         {
  34.             // zmiana znaku
  35.             znak += n;
  36.             while(!isalpha(znak))
  37.                 znak -= 26;
  38.         }
  39.         output << znak;
  40.     }
  41.  
  42.     input.close();
  43.     output.close();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment