Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int a[100][100],n,i,j,nr;
- float m1=0.0,m2=0.0;
- cout<<"n=";cin>>n;
- for (i=0;i<n;i++)
- for (j=0;j<n;j++)
- cin>>a[i][j];
- nr=0;
- for (i=0;i<n-1;i++)
- for (j=i+1;j<n;j++)
- if (a[i][j]>0) {
- m1+=a[i][j];
- nr++;
- }
- m1=(float)m1/(float)nr;
- nr=0;
- for (i=1;i<n;i++)
- for (j=0;j<i;j++)
- if (a[i][j]>0) {
- m2+=a[i][j];
- nr++;
- }
- m2=(float)m2/(float)nr;
- cout<<"dif:"<<abs(m1-m2)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement