▣ 입력설명
첫째 줄에는 정점의 수 N(1<=N<=20)와 간선의 수 M가 주어진다. 그 다음부터 M줄에 걸쳐 연
결정보와 거리비용이 주어진다.
▣ 출력설명
인접행렬을 출력하세요.
▣ 입력예제 1
6 9
1 2 7
1 3 4
2 1 2
2 3 5
2 5 5
3 4 5
4 2 2
4 5 5
6 4 5
▣ 출력예제 1
0 7 4 0 0 0
2 0 5 0 5 0
0 0 0 5 0 0
0 2 0 0 5 0
0 0 0 0 0 0
0 0 0 5 0 0
#include
using namespace std;
int map[25][25];
int main() {
int i,j,n,m,a,b,c; // node, edge
cin>>n>>m;
//무방향
// for(i=1;i<=m;i++){
// cin>>a>>b;
// map[a][b]=1;
// map[b][1]=1;
// }
//
//방향
// for(i=1;i<=m;i++){
// cin>>a>>b;
// map[a][b]=1;
// }
//가중치
for(i=1;i<=m;i++){
cin>>a>>b>>c;
map[a][b]=c;
}
for(i=1;i<=m;i++){
for(j=1;j<=m;j++){
cout<<map[i][j]<<" ";
}
cout<<endl;
}
return 0;
}