Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- using namespace std;
- typedef long long ll;
- const int maxn = 105;
- int adj[maxn][maxn];
- int main() {
- int n; // number of nodes(vertices)
- cin >> n;
- int m; // number of edges
- cin >> m;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- adj[i][j] = 0;
- }
- }
- for(int i = 0; i < m; i++) {
- int a, b, c;
- cin >> a >> b >> c;
- adj[a][b] = c;
- adj[b][a] = c;
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cout << adj[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment