Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- int main(int argc, char *argv[])
- {
- if (argc != 5) {
- std::cout << "params N M in.file out.file\n";
- return -1;
- }
- int N = atoi(argv[1]);
- int M = atoi(argv[2]);
- std::ifstream fin(argv[3], std::ios::in);
- if (!fin)
- {
- std::cout << "error opening file \n";
- return -1;
- }
- std::ofstream fout(argv[4]);
- int value;
- for (int i = 0; i < N; ++i)
- {
- for (int j = 0; j < M; ++j)
- {
- fin >> value;
- fout << (value%2 ? 1 : 0) << " ";
- }
- fout << std::endl;
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement