nhap ma tran,kiem tra 2 cot canh nhau co = nhau
/*nhap ma tran a(n*m),ktra xem co 2 cot dung canh nhau co tong bang nhau ko?*/
#include<stdio.h>
#include<conio.h>
int nhapmatran(int a[][100],int n,int m)
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
printf("nhap phan tu a[%d][%d] : ",i,j);
scanf("%d",&a[i][j]);
}
}
int inmatran(int a[][100],int n,int m)
{
int i,j;
for(i=0;i<n;i++)
{
printf("
");
for(j=0;j<m;j++)
printf("%d\t",a[i][j]);
}
}
int tongcot(int a[][100],int n,int j)
{
int i,s=0;
for(i=0;i<n;i++)
s=s+a[i][j];
return s;
}
int main()
{
int a[100][100];
int n,m,j,t=0;
printf("nhap so hang cua ma tran: ");scanf("%d",&n);
printf("nhap so cot cua ma tran: ");scanf("%d",&m);
nhapmatran(a,n,m);
printf("ma tran vua nhap la:
");
inmatran(a,n,m);
for(j=0;j<m;j++)
if(tongcot(a,n,j)==tongcot(a,n,j+1))
t++;
if(t==0)
printf("ma tran vua nhap khong co 2 cot canh nhau co tong bang nhau");
else
printf("ma tran vua nhap co 2 cot canh nhau co tong bang nhau");
getch();
return 0;
}
Bạn đang đọc truyện trên: AzTruyen.Top