MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / main

Method main

src/class133/ShowDetails.java:65–180  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

63 }
64
65 public static void main(String[] args) {
66 // 唯一解
67 // 1*x1 + 2*x2 - 1*x3 = 9
68 // 2*x1 - 1*x2 + 2*x3 = 7
69 // 1*x1 - 2*x2 + 2*x3 = 0
70 System.out.println("唯一解");
71 mat[1][1] = 1; mat[1][2] = 2; mat[1][3] = -1; mat[1][4] = 9;
72 mat[2][1] = 2; mat[2][2] = -1; mat[2][3] = 2; mat[2][4] = 7;
73 mat[3][1] = 1; mat[3][2] = -2; mat[3][3] = 2; mat[3][4] = 0;
74 gauss(3);
75 print(3);
76
77 // 矛盾
78 // 1*x1 + 1*x2 = 3
79 // 2*x1 + 2*x2 = 7
80 System.out.println("矛盾");
81 mat[1][1] = 1; mat[1][2] = 1; mat[1][3] = 3;
82 mat[2][1] = 2; mat[2][2] = 2; mat[2][3] = 7;
83 gauss(2);
84 print(2);
85
86 // 多解
87 // 1*x1 + 1*x2 = 3
88 // 2*x1 + 2*x2 = 6
89 System.out.println("多解");
90 mat[1][1] = 1; mat[1][2] = 1; mat[1][3] = 3;
91 mat[2][1] = 2; mat[2][2] = 2; mat[2][3] = 6;
92 gauss(2);
93 print(2);
94
95 // 表达式冗余,唯一解
96 // 1*x1 + 2*x2 - 1*x3 + 0*x4 = 9
97 // 2*x1 + 4*x2 - 2*x3 + 0*x4 = 18
98 // 2*x1 - 1*x2 + 2*x3 + 0*x4 = 7
99 // 1*x1 - 2*x2 + 2*x3 + 0*x4 = 0
100 System.out.println("表达式冗余,唯一解");
101 mat[1][1] = 1; mat[1][2] = 2; mat[1][3] = -1; mat[1][4] = 0; mat[1][5] = 9;
102 mat[2][1] = 2; mat[2][2] = 4; mat[2][3] = -2; mat[2][4] = 0; mat[2][5] = 18;
103 mat[3][1] = 2; mat[3][2] = -1; mat[3][3] = 2; mat[3][4] = 0; mat[3][5] = 7;
104 mat[4][1] = 1; mat[4][2] = -2; mat[4][3] = 2; mat[4][4] = 0; mat[4][5] = 0;
105 gauss(4);
106 print(4);
107
108 // 表达式冗余,矛盾
109 // 1*x1 + 2*x2 - 1*x3 = 9
110 // 2*x1 + 4*x2 - 2*x3 = 18
111 // 2*x1 - 1*x2 + 2*x3 = 7
112 // 4*x1 - 2*x2 + 4*x3 = 10
113 System.out.println("表达式冗余,矛盾");
114 mat[1][1] = 1; mat[1][2] = 2; mat[1][3] = -1; mat[1][4] = 0; mat[1][5] = 9;
115 mat[2][1] = 2; mat[2][2] = 4; mat[2][3] = -2; mat[2][4] = 0; mat[2][5] = 18;
116 mat[3][1] = 2; mat[3][2] = -1; mat[3][3] = 2; mat[3][4] = 0; mat[3][5] = 7;
117 mat[4][1] = 4; mat[4][2] = -2; mat[4][3] = 4; mat[4][4] = 0; mat[4][5] = 10;
118 gauss(4);
119 print(4);
120
121 // 表达式冗余,多解
122 // 1*x1 + 2*x2 - 1*x3 = 9

Callers

nothing calls this directly

Calls 3

gaussMethod · 0.95
printMethod · 0.95
printlnMethod · 0.45

Tested by

no test coverage detected