-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.cpp
More file actions
99 lines (99 loc) · 1.9 KB
/
Copy pathdata.cpp
File metadata and controls
99 lines (99 loc) · 1.9 KB
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
97
98
99
//data.cpp
//Àý×ÓÊý¾Ý
#include "headers.h"
//p141
int **Ex5_2Matrix(int &n)
{
int adjMat[][5] = {
{0, 3, 3, 2, 6},
{3, 0, 7, 3, 2},
{3, 7, 0, 2, 5},
{2, 3, 2, 0, 3},
{6, 2, 5, 3, 0}};
n = 5;
int **M = new2DArr(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
M[i][j] = adjMat[i][j];
return M;
}
int **Ex5_2aMatrix(int &n)
{
int adjMat[][4] = {
{0, 2, 5, 7},
{2, 0, 8, 3},
{5, 8, 0, 1},
{7, 3, 1, 0}};
n = 4;
int **M = new2DArr(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
M[i][j] = adjMat[i][j];
return M;
}
//p146
int **Ex5_3Matrix(int &n)
{
int adjMat[][8] = {
{ 0, 1, 4, 4,Inf,Inf,Inf,Inf},
{Inf, 0, 2,Inf, 9,Inf,Inf,Inf},
{Inf,Inf, 0, 3, 6, 3, 4,Inf},
{Inf,Inf,Inf, 0,Inf,Inf, 7,Inf},
{Inf,Inf,Inf,Inf, 0,Inf,Inf, 1},
{Inf,Inf,Inf,Inf, 2, 0,Inf, 5},
{Inf,Inf,Inf,Inf,Inf, 1, 0, 3},
{Inf,Inf,Inf,Inf,Inf,Inf,Inf, 0}};
n = 8;
int **M = new2DArr(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
M[i][j] = adjMat[i][j];
return M;
}
//p152
int **Ex5_4Matrix(int &n)
{
int adjMat[][6] = {
{ 0, 1, 3, 7,Inf,Inf},
{ 1, 0, 2,Inf, 9, 8},
{ 3, 2, 0, 5,Inf, 6},
{ 7,Inf, 5, 0,Inf, 4},
{Inf, 9,Inf,Inf, 0, 10},
{Inf, 8, 6, 4, 10, 0}};
n = 6;
int **M = new2DArr(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
M[i][j] = adjMat[i][j];
return M;
}
//p170
int **Ex6_1Matrix(int &n)
{
int adjMat[][4] = {
{ 0, 3, 6, 7},
{ 5, 0, 2, 3},
{ 6, 4, 0, 2},
{ 3, 7, 5, 0}};
n = 4;
int **M = new2DArr(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
M[i][j] = adjMat[i][j];
return M;
}
//p170, ¸Ä±ä´ÎÐòB<>D
int **Ex6_1aMatrix(int &n)
{
int adjMat[][4] = {
{ 0, 7, 6, 3},
{ 3, 0, 5, 7},
{ 6, 2, 0, 4},
{ 5, 3, 2, 0}};
n = 4;
int **M = new2DArr(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
M[i][j] = adjMat[i][j];
return M;
}