Mang2Chieu
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[2][2];
int i,j;
int sum=0;
for (int i=0;i<2;i++)
{
for (int j=0;j<2;j++)
{
printf("
Moi ban nhap vao gia tri arr[%d][%d] : ",i,j);
scanf("%d",&arr[i][j]);
}
}
printf("
Hien thi duoi dang ma tran cac so tren nhu sau :
");
for (i=0;i<2;i++)
{
for (j=0;j<2;j++)
{
printf("\t%d",arr[i][j]);
}
printf("
");
}
printf("
Cac so le trong mang da nhap la : ");
for (i=0;i<2;i++)
{
for (j=0;j<2;j++)
{
if (arr[i][j]%2!=0)
{
printf("
\t%d",arr[i][j]);
sum = sum + arr[i][j];
}
}
}
printf("
Tong cac so le trong mang la : %d",sum);
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top