Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. int m;
  7. cin >> n;
  8. cin >> m;
  9.  
  10. int **Graph = (int**)malloc(n*sizeof(int*));
  11. for (int i = 0; i < n; i++) {
  12. Graph[i] = (int*)malloc(n*sizeof(int));
  13. }
  14.  
  15. int c1, c2;
  16. for (int i = 0; i < m; i++) {
  17. cin >> c1;
  18. cin >> c2;
  19. Graph[c1-1][c2-1] = 1;
  20. }
  21.  
  22. for (int i = 0; i < n; i++) {
  23. for (int j = 0; j < n; j++) {
  24. if (Graph[i][j] != 1) Graph[i][j] = 0;
  25. cout << Graph[i][j] << " ";
  26. }
  27. cout << endl;
  28. }
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement