Untitled
raw download clone
TEXT
views 16
,
size 949 b
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin ("calcfunct.in");
ofstream fout ("calcfunct.out");

int maxim(int v[], int n)
{
    int maxim1 = (2<< 30), i;
    while(n >= 1)
    {
        if(v[n] > maxim1)
            maxim1 = v[n], i = n;
        n--;
    }
    return i;
}

void minim(int v[], int n, int& b)
{
   int a = 1000000001;
    while(n >= 1)
    {
        if(v[n] < a)
            a = v[n], b = n;
        n--;
    }
}

void schimba(int a, int b)
{
    int c = a;
    a = b;
    b = c;
}

void afiseaza(int v[], int pozint, int pozfin)
{
    for(int i = pozfin; i >= pozint; i--)
        fout << v[i] << ' ' ;
}

int v[101], n, a;

int main()
{
    fin >> n;
    for(int i = 1; i <= n; i ++)
        fin >> v[i];
    minim(v, n, a);
    int b = maxim(v, n);
    if(a < b)
        afiseaza(v, a, b);
    else
        afiseaza(v, b, a);
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.