Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     if (argc != 3) {
  8.         std::cout << "params in.file out.file\n";
  9.         return -1;
  10.     }
  11.  
  12.  
  13.     std::ifstream fin(argv[1], std::ios::in);
  14.  
  15.     if (!fin)
  16.     {
  17.         std::cout << "error\n";
  18.         return -1;
  19.     }
  20.     std::ofstream fout(argv[2]);
  21.     std::string str;
  22.     while(std::getline(fin, str))
  23.     {
  24.         std::stringstream ss(str);
  25.         std::string svalue;
  26.         while(std::getline(ss, svalue, ' '))
  27.         {
  28.             int value = std::stoi(svalue);
  29.             fout << (value%2 ? 1 : 0) << " ";
  30.         }
  31.         fout << std::endl;
  32.     }
  33.  
  34.     fin.close();
  35.     fout.close();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement