#include <fstream>
#include <random>
using namespace std;
int main() {
ofstream f_out("first.txt");
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dist(-10, 10);
int odd = -11;
for (int i = 0; i < 20; ++i) {
int rnd = dist(mt);
if (odd == -11 && rnd % 2 != 0)
odd = abs(rnd);
f_out << rnd << '\n';
}
f_out.close();
ifstream f_in("first.txt");
ofstream s_out("second.txt");
while (f_in.peek() != EOF) {
int tmp;
f_in >> tmp;
s_out << tmp + odd << '\n';
}
f_in.close();
s_out.close();
}
Объяснение: