Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
1.6 kB
4
Indexable
Never
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int array[20001];
    for(int i=0;i<n;i++)
    {
        cin>>array[i];
    }
    int max=-101;
    int min=101;
    int aver1=0;
    int aver2=0;
    int aver3=0;
    int aver4=0;
    if(n%4==0)
    {
         for(int i=0;i<n;i=i+4)
        {
            if((array[i]+array[i+1]+array[i+2]+array[i+3])/4 > max)
            {
                max = (array[i]+array[i+1]+array[i+2]+array[i+3])/4;
            }
            if((array[i]+array[i+1]+array[i+2]+array[i+3])/4 < min)
            {
                min = (array[i]+array[i+1]+array[i+2]+array[i+3])/4;
            }
            aver1+=array[i];
            aver2+=array[i+1];
            aver3+=array[i+2];
            aver4+=array[i+3];
        }
    }
    else{
        for(int i=0;i<n-n%4;i=i+4)
        {
            if((array[i]+array[i+1]+array[i+2]+array[i+3])/4 > max)
            {
                max = (array[i]+array[i+1]+array[i+2]+array[i+3])/4;
            }
            if((array[i]+array[i+1]+array[i+2]+array[i+3])/4 < min)
            {
                min = (array[i]+array[i+1]+array[i+2]+array[i+3])/4;
            }
            aver1+=array[i];
            aver2+=array[i+1];
            aver3+=array[i+2];
            aver4+=array[i+3];
        }
    }
    aver1=aver1/(n/4);
    aver2=aver2/(n/4);
    aver3=aver3/(n/4);
    aver4=aver4/(n/4);
    cout<<min<<' '<<max<<endl;
    cout<<aver1<<' '<<aver2<<' '<<aver3<<' '<<aver4<<endl;
    return 0;
}