Skip to content

Commit ff327a9

Browse files
Update euler.cpp
1 parent aabea88 commit ff327a9

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

euler.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,52 @@
22
#include <list>
33
using namespace std;
44

5-
class Graph
6-
{
5+
class Graph {
76
int V;
87
list<int>* adj;
98
public:
10-
Graph(int V)
11-
{
9+
Graph(int V) {
1210
this->V = V;
1311
adj = new list<int>[V];
1412
}
15-
~Graph()
16-
{
13+
14+
~Graph() {
1715
delete[] adj;
1816
}
1917

2018
void addEdge(int v, int w);
2119
};
2220

23-
void Graph::addEdge(int v, int w)
24-
{
21+
void Graph::addEdge(int v, int w) {
2522
adj[v].push_back(w);
2623
adj[w].push_back(v);
2724
}
2825

29-
int main()
30-
{
26+
int main() {
3127
ios_base::sync_with_stdio(false);
3228
cin.tie(NULL);
3329
int N, M;
3430
cin >> N >> M;
3531
int u[100], v[100], counter[100];
32+
3633
Graph g(N);
37-
for (int i = 0; i < M; i++)
38-
{
34+
for (int i = 0; i < M; i++) {
3935
cin >> u[i] >> v[i];
4036
g.addEdge(u[i], v[i]);
4137
}
42-
for (int i = 0; i < N; i++)
43-
{
38+
for (int i = 0; i < N; i++) {
4439
counter[i] = 0;
45-
for (int j = 0; j < M; j++)
46-
{
40+
for (int j = 0; j < M; j++) {
4741
if (u[j] == i or v[j] == i)
4842
counter[i]++;
4943
}
5044
}
45+
5146
int result = 0;
5247
int min = -1;
5348
int max = -1;
54-
for (int j = 0; j < N; j++)
55-
{
56-
if (counter[j] % 2 != 0)
57-
{
49+
for (int j = 0; j < N; j++) {
50+
if (counter[j] % 2 != 0) {
5851
result++;
5952
if (min == max)
6053
min = j;

0 commit comments

Comments
 (0)