#include <stdio.h>#include <conio.h>#define MAXD 50#define MAXC 100void nhapmatran(int a[][MAXC],int m,int n);void xuatmatran(int a[][MAXC],int m,int n);int tinhtong(int a[][MAXC],int m,int n);void main(){ clrscr();int b[MAXD][MAXC],m,n,kq;printf("Nhap ma tran: ");scanf("%d %d",&m,&n);nhapmatran(b,m,n);xuatmatran(b,m,n);kq=tinhtong(b,m,n);printf("\nGia tri tong la:%d",kq);getch();}int tinhtong(int a[][MAXC],int m,int n){int s=0;for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(i<j)s=s+a[i][j];return s;}void nhapmatran(int a[][MAXC],int m,int n){for (int i=0;i<n;i++)for (int j=0;j<m;j++){printf("\n Nhap a[%d][%d]=",i,j);scanf("%d",&a[i][j]);}}void xuatmatran(int a[][MAXC],int m,int n){for (int i=0;i<n;i++)for (int j=0;j<m;j++){printf("\na[%d][%d]=%d",i,j,a[i][j]);}}
Tags:
lập trình c