#include<stdio.h>
#include<conio.h>
#define MAX 10
void nhap(int a[MAX][MAX],int &d,int &c)
{
do
{
printf("nhap vao so dong cua mang: ");
scanf("%d",&d);
printf("nhap vao so cot cua mang: ");
scanf("%d",&c);
}
while(d<1||d>MAX||c<1||c>MAX) ;
printf("nhap mang co %d dong %d cot \n",d,c);
for(int i=0;i<d;i++)
for(int j=0;j<c;j++)
{
printf("a[%d][%d]: ",i,j);
scanf("%d",&a[i][j]);
}
}
void cottongmin(int a[MAX][MAX],int d,int c)
{
int i,j,sum=0,summin=0,cotthu;
for (j=0;j<c;j++)
{
for (i=0;i<d;i++)
{
sum+=a[i][j];
if (j==0)
summin=sum;
}
if (sum<summin)
{
summin=sum;
cotthu=j+1;
}
sum=0;
}
printf("Cot co tong nho nhat la cot thu %d,voi tong = %d",cotthu,summin);
}
void xuat(int a[MAX][MAX],int d,int c)
{
for(int i=0;i<d;i++)
{
for(int j=0;j<c;j++)
printf(" %d ",a[i][j]);
printf("\n");
}
}
void main()
{
int a[MAX][MAX],d,c;
nhap(a,d,c);
printf("mang ban vua nhap la:\n");
xuat(a,d,c);
cottongmin(a,d,c);
getch();
}