Advertisement
Guest User

Untitled

a guest
Oct 9th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.     int n,i,j;
  7.     float m[52][51];
  8.     cin>>n;
  9.    
  10.     for (i = 1; i <= n; i++)
  11.         for (j = 1; j <= n; j++)
  12.             cin>>m[i][j];
  13.    
  14.     for (i = 1; i <= n; i++) {
  15.         float suma = 0;
  16.        
  17.             for (j = 1; j <= n; j++)
  18.                 suma += m[j][i];
  19.        
  20.             for (j = n + 1; j > n/2 + 1; j--)
  21.                 m[j][i] = m[j - 1][i];
  22.        
  23.             m[n/2 + 1][i] = suma/n;
  24.     }
  25.     for (i = 1; i <= n + 1; i++) {
  26.         for (j = 1; j <= n; j++)
  27.             cout<<m[i][j]<<" ";
  28.         cout<<'\n';
  29.     }
  30.    
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement