Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <bitset>
  4. #include <vector>
  5. #include <string>
  6. #include <algorithm>
  7.  
  8. using namespace std;
  9.  
  10. int main(int argc, char *argv[]) {
  11.  
  12.  
  13.     string filename = argv[1];
  14.     fstream fs;
  15.     string file = "/gpfs/home/VGabov/peresdacha1/";
  16.     file+=filename;
  17.  
  18.  
  19.     fs.open(file);
  20.  
  21.     // Чтение из файла в байтах
  22.     char b;
  23.     vector< bitset<8> > v;
  24.     while (fs >> b) {
  25.         v.push_back(bitset<8>(b));
  26.     }
  27.  
  28.     // Реверс байтов
  29.     reverse(begin(v), end(v));
  30.  
  31.     // Реверс имени
  32.     reverse(begin(filename), end(filename));
  33.  
  34.     // Запить в файл
  35.     ofstream out;
  36.     out.open(filename);
  37.     for(auto i : v) {
  38.         out << i << " ";
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement