SHARE
TWEET

Untitled

a guest Feb 27th, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  8.  
  9. int main()
  10. {
  11.     int n,m,i,j,l;
  12.     float p;
  13.    
  14.     cin>>n;
  15.     cin>>m;
  16.     int a[n][m];
  17.     for(i=0;i<n;i++){
  18.         for(j=0;j<m;j++){
  19.             cin>>a[i][j];
  20.             if(i==j){
  21.                 p=p+a[i][j];
  22.                 l++;
  23.             }
  24.        
  25.         }
  26.     }
  27.     for(i=0;i<n;i++){
  28.         for(j=0;j<m;j++)
  29.         {
  30.             cout <<a[i][j];
  31.         }
  32.         cout<<endl;
  33.     }
  34.     cout << endl;
  35.     cout << p/l;
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top