Advertisement
Guest User

Untitled

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