Untitled

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

using namespace std;

const string filename = "input.txt";

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

int main()
{
	const int size = 100;
	int n;
	int a;
	int mass[100];

	readMas(mass, size, n);
	for (int i = 0; i < n; i++)
	{
		cout << mass[i] << " ";

	}

}
Leave a Comment