#include #include #include #include const std::size_t N = 512, NAME = 10; const std::string path = "/tmp/"; std::random_device device; std::default_random_engine engine(device()); std::uniform_int_distribution distribution(0, NAME - 1); auto rng = std::bind(distribution, engine); void work(std::size_t begin, std::size_t end) { for (std::size_t i = begin; i < end; ++i) { std::size_t x = 0, max = 0; try { std::ifstream ifs(path + std::to_string(rng()) + ".txt", std::ios::in); while (ifs) { ifs >> x; max = std::max(max, x); } std::ofstream ofs(path + std::to_string(rng()) + ".txt", std::ios::app); ofs << max + 1 << std::endl; } catch (...) { } } }