-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBai39.cpp
85 lines (71 loc) · 1.16 KB
/
Bai39.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
/*
Con trỏ và mảng hai chiều
+, -, ++, --, <, >, >=, <= , ==
*/
#include <iostream>
using namespace std;
#define N 100
void showResult0(int* a) {
for (size_t i = 0; i < 10; i++)
{
cout << *(a + i) << " ";
}
}
void showResult(int a[][10]) {
for (size_t i = 0; i < 10; i++)
{
for (size_t j = 0; j < 10; j++)
{
cout << *(*(a + i) + j) << " ";
}
cout << endl;
}
}
void showResult1(int* a[N]) {
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 3; j++)
{
cout << *(*(a + i) + j) << " ";
}
cout << endl;
}
}
void showResult2(int** a) {
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 3; j++)
{
cout << *(*(a + i) + j) << " ";
}
cout << endl;
}
}
int main() {
int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
//showResult0(arr);
int a[10][10] = {};
int* b[10];
for (size_t i = 0; i < 10; i++)
{
b[i] = new int[10];
}
int** c = new int* [3];
for (size_t i = 0; i < 3; i++)
{
c[i] = new int[3];
}
for (size_t i = 0; i < 3; i++)
{
for (size_t j = 0; j < 3; j++)
{
c[i][j] = i + j;
}
}
showResult(a);
//showResult1(b);
//showResult2(b);
//showResult1(c);
//showResult2(c);
return 0;
}