You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
675 B

#include <bits/stdc++.h>
using namespace std;
const int N = 1010; //图的最大点数量
int n;
int v[N][N]; //邻接矩阵
/**
* 测试数据
4
0 5 2 3
5 0 0 1
2 0 0 4
3 1 4 0
*/
int main() {
cin >> n;
//读入到邻接矩阵
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
cin >> v[i][j];
//下面的代码将找到与点i有直接连接的每一个点以及那条边的长度
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (v[i][j]) cout << "edge from point "
<< i << " to point " << j << " with length " << v[i][j] << endl;
return 0;
}