Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<vector>
- #include<list>
- using namespace std;
- int main()
- {
- int v,a,b,k=1,i;
- int adj[100][100];
- cout<<"Input No Of Vertex: ";
- cin>>v;
- do
- {
- //cout<<"Input No Of Edges"<<endl;
- cout<<"Edge "<<k<<endl;
- cin>>a>>b;
- if(a<=v && b<=v)
- {
- adj[a][b]=1;
- adj[b][a]=1;
- k++;
- }
- else
- {
- cout<<"Invalid Input,Try Again!!"<<endl;
- }
- } while(a!=0 || b!=0);
- int j ;
- for(i=0;i<v;i++)
- {
- for(j=0;j<v;j++)
- printf("%d ",adj[i][j]);
- printf("\n");
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment