Advertisement
-Vizion-

var90_2009_s2_5

Nov 14th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. int a[25][25];
  6. int main ()
  7. {
  8.     int  i,j,n,c1=0,c2=0;
  9.     float s1=0,s2=0,m1,m2,rez;
  10.     cin>>n;
  11.     for (i=1;i<=n;i++)
  12.     {
  13.         for (j=1;j<=n;j++)
  14.         {
  15.             cin>>a[i][j];
  16.         }
  17.     }
  18.     for (i=1;i<=n;i++)
  19.     {
  20.         for (j=1;j<=n;j++)
  21.         {
  22.             if (i<j)
  23.             {
  24.                 if (a[i][j]>0)
  25.                 {
  26.                     s1=s1+a[i][j];
  27.                     c1++;
  28.                 }
  29.             }
  30.             else if (i>j)
  31.             {
  32.                 if (a[i][j]>0)
  33.                 {
  34.                     s2=s2+a[i][j];
  35.                     c2++;
  36.                 }
  37.             }
  38.         }
  39.     }
  40.     m1=1.00*s1/c1;
  41.     m2=1.00*s2/c2;
  42.     cout<<setprecision(2)<<fixed<<floor((m1-m2)*100)/100;
  43.     return 0;
  44. }
  45. /*
  46. -1 2 -4 5
  47. 0 6 3 1
  48. 2 4 2 0
  49. 3 -5 1 -3
  50. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement