Advertisement
STANAANDREY

med_m_pat

May 20th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int a[100][100],n,i,j,nr;
  7. float m1=0.0,m2=0.0;
  8. cout<<"n=";cin>>n;
  9. for (i=0;i<n;i++)
  10. for (j=0;j<n;j++)
  11.     cin>>a[i][j];
  12. nr=0;
  13. for (i=0;i<n-1;i++)
  14.     for (j=i+1;j<n;j++)
  15.     if (a[i][j]>0) {
  16.     m1+=a[i][j];
  17.     nr++;
  18.     }
  19.     m1=(float)m1/(float)nr;
  20.     nr=0;
  21.    for (i=1;i<n;i++)
  22.    for (j=0;j<i;j++)
  23.    if (a[i][j]>0) {
  24.     m2+=a[i][j];
  25.     nr++;
  26.    }
  27.   m2=(float)m2/(float)nr;
  28.  cout<<"dif:"<<abs(m1-m2)<<endl;
  29.   return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement