fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m;
  6. cin>>n>>m;
  7. int graph[n][n];
  8. for(int i=0;i<m;i++){
  9. int x,y;
  10. cin>>x>>y;
  11. graph[x][y]=1;
  12. graph[y][x]=1;
  13. }
  14. for(int i=0;i<n;i++){
  15. for(int j=0;j<n;j++){
  16. if(graph[i][j]==1){
  17. cout<<"("<<i<<" "<<j<<")";
  18. }
  19. }
  20. cout<<"\n";
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 5296KB
stdin
3 2
0 1
1 2
stdout
(0 1)
(1 0)(1 2)
(2 1)