zad7

 avatar
user_1041599
c_cpp
a month ago
620 B
1
Indexable
2kolok_SP
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;

int main() {
    int m,n;
    cin>>m>>n;
    int arr[m][n];

    for(int i=0;i<m;i++) {
        float sum=0;
        float avg;
        for(int j=0;j<n;j++) {
            cin>>arr[i][j];
            sum+=arr[i][j];
        }
        avg=sum/(float)n;
        float maxDistance = -1;
        float maxValue = 0;
        for(int j=0;j<n;j++) {
            if (abs(arr[i][j]-avg)>maxDistance) {
                maxDistance = abs(arr[i][j]-avg);
                maxValue = arr[i][j];
            }
        }
        cout<<maxValue<<" ";
    }

}
Leave a Comment