Znajdowanie minimum z n liczb – przykład 2

#include
#include

using namespace std;

int LiczbaElementow, MinWartosc;

int MinN1(int n)
{
int i, x, minx;
minx=INT_MAX;
cout <<“INT_MAX= ” << INT_MAX<< endl;
for(i=0; i<n; i++)
{
cout << “minx= “<< minx << endl << “Podaj liczbe ” << i+1 << “: “; cin >> x;
if(x<minx)
minx = x;
}
return minx;
}

int MinN2(int n)
{
int i, x, minx;
for(i=0; i<n; i++)
{
cout << “Podaj liczbe ” << i+1 << “: “; cin >> x;
if(i==0)
minx = x;
else
if(x<minx)
minx = x;
}
return minx;
}

int main()
{
cout << “Podaj liczbe elementow: “; cin >> LiczbaElementow;
cout << “Podaj elementy:” << endl;
MinWartosc = MinN1(LiczbaElementow);
cout << “Minimum to ” << MinWartosc << endl;
cout << “Podaj elementy:” << endl;
MinWartosc = MinN2(LiczbaElementow);
cout << “Minimum to ” << MinWartosc << endl;
return 0;
}