summaryrefslogtreecommitdiff
path: root/graphs/task1.cpp
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-03-30 12:54:19 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-03-30 12:54:19 +0400
commit6b5d47f8792b9a9d89939a48f2e88771c8a3bbfa (patch)
tree1627a4c047f38e6e771acb2a7a34033bbfa54f0e /graphs/task1.cpp
parenta78c434472b9e72ea479f672d6f85789dd19db2e (diff)
Исправил первую задачу в графах
Diffstat (limited to 'graphs/task1.cpp')
-rw-r--r--graphs/task1.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/graphs/task1.cpp b/graphs/task1.cpp
index 1fea795..af9aba3 100644
--- a/graphs/task1.cpp
+++ b/graphs/task1.cpp
@@ -1,5 +1,6 @@
#include<iostream>
#include<vector>
+#include<algorithm>
using namespace std;
@@ -57,8 +58,16 @@ int main()
cin >> q;
q--;
+ int deg_m = int(g[q].size());
+ int deg_p = 0;
+ for (int i = 0; i < int(g.size()); ++i)
+ {
+ if (find(g[i].begin(), g[i].end(), q) != g[i].end())
+ ++deg_p;
+ }
+
cout << "С данной вершиной смежны "
- << g[q].size()
+ << deg_m + deg_p
<< " вершин" << endl;
return 0;