/
wFqKUAK8.cpp
96 lines (87 loc) · 1.98 KB
/
wFqKUAK8.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
Sưu tầm bởi @nguyenvanhieuvn
Thực hành nhiều bài tập hơn tại https://luyencode.net/
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 100
void NhapMang(float a[][MAX], int &dong, int &cot)
{
//Nhập số dòng
do
{
printf("\nNhap vao so dong: ");
// Cách tà đạo: scanf("dong =%d",&dong); // Lúc nhập phải viết thêm chữ ( dong = ) ở khung console
scanf("%d",&dong);
if(dong < 1 || dong > MAX)
{
printf("\nSo dong khong hop le. Xin kiem tra lai!");
}
}while(dong < 1 || dong > MAX);
//Nhập số cột
do
{
printf("\nNhap vao so cot: ");
scanf("%d",&cot);
if(cot < 1 || cot > MAX)
{
printf("\nSo cot khong hop le. Xin kiem tra lai!");
}
}while(cot < 1 || cot > MAX);
for(int i = 0; i < dong; i++)
{
for(int j = 0; j < cot; j++)
{
float temp;
printf("\nNhap a[%d][%d] = ", i, j);
scanf("%f", &temp);
a[i][j] = temp;
}
}
}
void XuatMang(float a[][MAX], int dong, int cot)
{
for(int i = 0; i < dong; i++)
{
for(int j = 0; j < cot; j++)
{
printf("%8.3f", a[i][j]);
}
printf("\n\n");
}
}
void LietKeCacDongToanAm(float a[][MAX], int dong, int cot)
{
int flag;
for(int i = 0; i < dong; i++)
{
flag = 1;
for(int j = 0; j < cot; j++)
{
if(a[i][j] > 0)
{
flag = 0;
break;
}
}
if(flag == 1)
{
printf("\nDong %d toan am: ", i);
for(int j = 0; j < cot; j++)
{
printf("\%8.3f", a[i][j]);
}
}
}
}
int main()
{
float a[MAX][MAX];
int dong, cot;
NhapMang(a, dong, cot);
XuatMang(a, dong, cot);
LietKeCacDongToanAm(a, dong, cot);
getch();
return 0;
}