zad7
gorazd
c_cpp
10 months ago
620 B
4
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<<" ";
}
}Editor is loading...
Leave a Comment