Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- int main(int argc, char *argv[])
- {
- if (argc != 3) {
- std::cout << "params in.file out.file\n";
- return -1;
- }
- std::ifstream fin(argv[1], std::ios::in);
- if (!fin)
- {
- std::cout << "error\n";
- return -1;
- }
- std::ofstream fout(argv[2]);
- std::string str;
- while(std::getline(fin, str))
- {
- std::stringstream ss(str);
- std::string svalue;
- while(std::getline(ss, svalue, ' '))
- {
- int value = std::stoi(svalue);
- fout << (value%2 ? 1 : 0) << " ";
- }
- fout << std::endl;
- }
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement