Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- int m;
- cin >> n;
- cin >> m;
- int **Graph = (int**)malloc(n*sizeof(int*));
- for (int i = 0; i < n; i++) {
- Graph[i] = (int*)malloc(n*sizeof(int));
- }
- int c1, c2;
- for (int i = 0; i < m; i++) {
- cin >> c1;
- cin >> c2;
- Graph[c1-1][c2-1] = 1;
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (Graph[i][j] != 1) Graph[i][j] = 0;
- cout << Graph[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement