#include <iostream>
using namespace std;
int main(){
int a,b,n,m,map[101][101];
cin>>n>>m;
for(int i = 1;i <= m;i++){
cin>>a>>b;
map[a][b] = 1;
map[b][a] = 1;
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
cout<<map[i][j];
}
cout<<endl;
}
return 0;
}
【图的输入】
最新推荐文章于 2025-12-19 15:39:34 发布
该程序读取两个整数n和m,然后输入n个节点之间的边,用邻接矩阵表示这些边,并打印出来。它涉及到基本的C++输入输出和二维数组操作。
6066

被折叠的 条评论
为什么被折叠?



