Untitled

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

using namespace std;

const string inputName = "input.txt";

void read(vector<int>& num){

	ifstream in(inputName.c_str());
	if (!in.is_open()) {
		cout << "Some get wrong" << "\n";
	}
	int n;
	while (in >> n) {
		num.push_back(n);
	}
	in.close();

}
int countPrimes(vector<int> num) {
	int count{};
	for (int i : num) {
		for (int j = 2; j <= i / 2; j++)
			if (i % j == 0) { 
				count += 1; 
				break;
			}
	}
	return num.size() - count;

}
int main(){

	vector<int> num{};
	read(num);
	cout << inputName << " " << num.size() << " " << countPrimes(num);


}
Leave a Comment