Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
799 B
0
Indexable
Never
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

const string inputName = "input.txt";
const string outputName = "output.txt";
const int d = 10;

void read(vector<int>& num){

	ifstream in(inputName.c_str());
	if (!in.is_open()) {
		cout << "Some get wrong" << "\n";
	}
	int n{}, a{};
	in >> n;
	for (int i = 0; i < n; i++) {
		in >> a;
		num.push_back(a);
	}

}

void encrypt(vector<int> &num) {
	for (int& i : num) {
		i += d;
	}
}

void write(vector<int> num) {

	ofstream out(outputName.c_str());
	if (!out.is_open()) {
		cout << "Some get wrong" << "\n";
	}
	for (int i : num) {
		out << i << "\n";
	}
	out.close();
}

int main(){

	vector<int> num{};
	read(num);
	encrypt(num);
	write(num);

}
Leave a Comment