#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, e, i, j, x, y;
cout << "Enter Node Number :: ";
cin >> n;
cout << "Enter Edge Number :: ";
cin >> e;
int a[n][n];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j] = 0;
}
}
cout << endl <<"Enter Edge :: " << endl;
for(i=1;i<=e;i++)
{
cin >> x >> y;
a[x][y] = 1;
a[y][x] = 1;
}
cout << endl << "Matrix :: " << endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
using namespace std;
int main()
{
int n, e, i, j, x, y;
cout << "Enter Node Number :: ";
cin >> n;
cout << "Enter Edge Number :: ";
cin >> e;
int a[n][n];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j] = 0;
}
}
cout << endl <<"Enter Edge :: " << endl;
for(i=1;i<=e;i++)
{
cin >> x >> y;
a[x][y] = 1;
a[y][x] = 1;
}
cout << endl << "Matrix :: " << endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
Comments
Post a Comment