summaryrefslogtreecommitdiff
path: root/graphs/task1_1.cpp
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-03-29 12:33:14 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-03-29 12:33:14 +0400
commit8557b2421ffc5ab15e9aaf50a7dc07f97a926f4e (patch)
tree67204adfc1f2f94257be61715ec9a5ff5afc3310 /graphs/task1_1.cpp
parent9bd6de066bea5ff3f5481db11f88b8463a94ff04 (diff)
Добавил первую задачу
Diffstat (limited to 'graphs/task1_1.cpp')
-rw-r--r--graphs/task1_1.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/graphs/task1_1.cpp b/graphs/task1_1.cpp
new file mode 100644
index 0000000..3963f5e
--- /dev/null
+++ b/graphs/task1_1.cpp
@@ -0,0 +1,40 @@
+#include<iostream>
+#include<vector>
+
+using namespace std;
+
+
+int main()
+{
+ cout << "Введите количество вершин: ";
+ int n;
+ cin >> n;
+
+ cout << "Введите количество рёбер: ";
+ int k;
+ cin >> k;
+
+ vector<vector<int>> graph(n);
+
+ cout << "Введите рёбра (неориентированные), нумерация с 1:" << endl;
+ for (int i = 0; i < k; ++i)
+ {
+ int a, b;
+ cin >> a >> b;
+ a--;
+ b--;
+ graph[a].push_back(b);
+ graph[b].push_back(a);
+ }
+
+ cout << "Введите исследуемую вершину: ";
+ int q;
+ cin >> q;
+ q--;
+
+ cout << "С данной вершиной смежны "
+ << graph[q].size()
+ << " вершин" << endl;
+
+ return 0;
+}