Advertisement
-Vizion-

var88_2009_s2_5

Nov 14th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 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,c=0;
  9.     float s=0,m;
  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.                     s=s+a[i][j];
  27.                     c++;
  28.                 }
  29.  
  30.             }
  31.         }
  32.     }
  33.     m=1.00*s/c;
  34.     cout<<setprecision(2)<<fixed<<floor(m*100)/100;
  35.     return 0;
  36. }
  37. /*
  38. -1 2 -4 5
  39. 0 6 3 1
  40. 2 4 2 0
  41. 3 -5 1 -3
  42. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement