| 142 | // 验证的过程 |
| 143 | // 为了测试 |
| 144 | public static boolean check() { |
| 145 | // near1方法会设置to1、dist1、to2、dist2 |
| 146 | near1(); |
| 147 | // 把near1方法的结果备份 |
| 148 | for (int i = 1; i <= n; i++) { |
| 149 | a[i] = to1[i]; |
| 150 | b[i] = dist1[i]; |
| 151 | c[i] = to2[i]; |
| 152 | d[i] = dist2[i]; |
| 153 | } |
| 154 | // near2方法会再次设置to1、dist1、to2、dist2 |
| 155 | near2(); |
| 156 | // a、b、c、d,是near1生成的结果 |
| 157 | // to1、dist1、to2、dist2,是near2生成的结果 |
| 158 | for (int i = 1; i <= n; i++) { |
| 159 | if (a[i] != to1[i] || b[i] != dist1[i]) { |
| 160 | return false; |
| 161 | } |
| 162 | } |
| 163 | for (int i = 1; i <= n; i++) { |
| 164 | if (c[i] != to2[i] || d[i] != dist2[i]) { |
| 165 | return false; |
| 166 | } |
| 167 | } |
| 168 | return true; |
| 169 | } |
| 170 | |
| 171 | // 对数器 |
| 172 | // 为了测试 |