Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
556 B
1
Indexable
Never
#include <iostream>
#include <fstream>

using namespace std;

const string filename = "input.txt";

void read1(int& n) {
	ifstream in(filename);
	if (!in.is_open()) {
		cout << "error"; return;
	}
	in >> n;
	in.close();
}
void read(int* mass) {
	ifstream in(filename);
	int a;
	int n;
	in >> n;
	for (int i = 0; i < n; i++)
	{
		in >> a;
		mass[i] = a;
	}
	in.close();
}

int main()
{
	int n;
	int a;
	read1(n);
	int* mass = new int [n];
	read(mass);
	for (int i = 0; i < n; i++)
	{
		cout << mass[i] << " ";

	}

}
Leave a Comment