-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathds question 16.cpp
67 lines (58 loc) · 942 Bytes
/
ds question 16.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<iostream>
#include<math.h>
using namespace std;
class graphs
{
int n;
int **a;
public:
void check();
void display();
void input();
};
void graphs::input()
{
cout<<"Enter the number of vertices in graph"<<endl;
cin>>n;
a=new int *[n];
for(int i=0;i<n;i++)
a[i]=new int[n];
cout<<"Enter the matrix"<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cin>>a[i][j];
}
}
void graphs::display()
{
cout<<"The matrix is "<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
}
void graphs::check()
{
int c=0,s=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
if(i==j&&a[i][j]==1)
s++;
}
int p=pow(n,2);
if(s!=0)
cout<<"It is not a complete graph"<<endl;
else
cout<<"It is a complete graph"<<endl;
}
int main()
{
graphs g1;
g1.input();
g1.display();
g1.check();
}