Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main()
- {
- int n,m,i,j,l;
- float p;
- cin>>n;
- cin>>m;
- int a[n][m];
- for(i=0;i<n;i++){
- for(j=0;j<m;j++){
- cin>>a[i][j];
- if(i==j){
- p=p+a[i][j];
- l++;
- }
- }
- }
- for(i=0;i<n;i++){
- for(j=0;j<m;j++)
- {
- cout <<a[i][j];
- }
- cout<<endl;
- }
- cout << endl;
- cout << p/l;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement