fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int node, edge;
  7. cin>>node>>edge;
  8.  
  9. int graph[node+1][node+1];
  10. memset(graph, 0, sizeof(graph));
  11.  
  12. int u, v;
  13. for(int i = 1; i <= edge; i++)
  14. {
  15. cin>>u>>v;
  16. graph[u][v] = 1;
  17. graph[v][u] = 1;
  18. }
  19.  
  20.  
  21. for(int i = 1; i <= node; i++)
  22. {
  23. for(int j = 1; j <= node; j++)
  24. {
  25. cout<<graph[i][j]<<" ";
  26. }
  27. cout<<endl;
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. }
  36.  
Success #stdin #stdout 0.01s 5284KB
stdin
4 5
1 2
2 3
3 4
4 1
2 4
stdout
0 1 0 1 
1 0 1 1 
0 1 0 1 
1 1 1 0