// Zadatak01.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

void UcitajBrojeve(int* poljeBrojeva, int velicinaPolja)
{
    for (int i = 0; i < velicinaPolja; i++)
    {
        cout << "Unesite " << (i + 1) << ". broj: ";
        cin >> poljeBrojeva[i];
    }
}

void IspisPolja(int* poljeBrojeva, int velicinaPolja)
{
    //normalni ispis
    cout << "NORMALNI ISPIS POLJA" << endl;
    for (int i = 0; i < velicinaPolja; i++)
    {
        cout << poljeBrojeva[i] << " ";
    }
    cout << endl;

    //obrnuti ispis
    cout << "OBRNUTI ISPIS POLJA" << endl;
    for (int i = velicinaPolja - 1; i >= 0; i--)
    {
        cout << poljeBrojeva[i] << " ";
    }
    cout << endl;
}

int GetSumaBrojeva(int* poljeBrojeva, int velicinaPolja)
{
    int zbroj = 0;
    for (int i = 0; i < velicinaPolja; i++)
    {
        zbroj += poljeBrojeva[i];
    }
    return zbroj;
}

double AritmetickaSredinaPolja(int* poljeBrojeva, int velicinaPolja)
{
    return GetSumaBrojeva(poljeBrojeva, velicinaPolja) / 5.0;
}

void DefinirajMinMax(int* poljeBrojeva, int velicinaPolja, int* min, int* max)
{
    *min = poljeBrojeva[0];
    *max = poljeBrojeva[0];

    for (int i = 0; i < velicinaPolja; i++)
    {
        if (poljeBrojeva[i] < *min)
            *min = poljeBrojeva[i];
        if (poljeBrojeva[i] > *max)
            *max = poljeBrojeva[i];
    }
}
int main()
{
    int poljeBrojeva[5];
    int min, max;

    UcitajBrojeve(poljeBrojeva, 5);
    cout << endl;
    IspisPolja(poljeBrojeva, 5);
    cout << endl;
    cout << "SUMA: " << GetSumaBrojeva(poljeBrojeva, 5) << endl;
    cout << "SRITMETICKA SREDINA: " << AritmetickaSredinaPolja(poljeBrojeva, 5) << endl;
    DefinirajMinMax(poljeBrojeva, 5, &min, &max);
    cout << "MIN: " << min << endl;
    cout << "MAX: " << max;
}



// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
