int main() { std::vector numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 1, 1, 2, 2}; int numToSearch; int count = 0;
std::cout << "Enter a number to search in the array: "; std::cin >> numToSearch; for(int num : numbers) { if(num == numToSearch) { count++; } } std::cout << "The number " << numToSearch << " occurs " << count << " times in the array." << std::endl; return 0;
int main() {
std::cout << "Enter a number to search in the array: ";std::vector numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 1, 1, 2, 2};
int numToSearch;
int count = 0;
std::cin >> numToSearch;
for(int num : numbers) {
if(num == numToSearch) {
count++;
}
}
std::cout << "The number " << numToSearch << " occurs " << count << " times in the array." << std::endl;
return 0;
}