Untitled

mail@pastecode.io avatar
unknown
c_cpp
15 days ago
869 B
1
Indexable
Never
#include <iostream>
#include <array>

int main()
{
    const int MAX_SIZE = 10;
    std::array< int, MAX_SIZE > numbers{};

    int n;

    std::cout << "Podaj ile liczb, chcesz wczytac: ";
    std::cin >> n;

    std::cout << "Podaj " << n << " liczb calkowitych\n";
    for( int i = 0; i < n; ++i )
    {
        std::cout << "Liczba " << i + 1 << ": ";
        std::cin >> numbers[ i ];
    }

    std::cout << "Wypisanie wszystkich liczb calkowitych\n";
    for( int i = 0; i < n; ++i )
    {
        std::cout << numbers[ i ] << " ";
    }
    std::cout << "\n\n";

    int maxNumber = numbers[ 0 ];
    for( int i = 1; i < n; ++i )
    {
        if( maxNumber < numbers[ i ] )
        {
            maxNumber = numbers[ i ];
        }
    }

    std::cout << "Najwieksza z nich to: " << maxNumber << '\n';

    return 0;
}
Leave a Comment