Поиск элемента в одномерном массиве из 5 элементов — C++(Си)

#include <iostream>
 
int main()
{
    const size_t SIZE = 5;
    int arr[SIZE];
    std::cout << "Input elements of the array" << std::endl;
    for(size_t i = 0; i < SIZE; ++i)
    {
        std::cout << "Input the element #" << i + 1 << ": ";
        std::cin >> arr[i];
    }
    int cmp;
    std::cout << "Input an integer for compare: ";
    std::cin >> cmp;
    for(size_t i = 0; i < SIZE; ++i)
        std::cout << "Element #" << i + 1 << ": "
                  << (cmp == arr[i] ? "matched" : "no match") << std::endl;
    system("pause");
    return EXIT_SUCCESS;
}

Leave a Comment