From 5e6dc29068bf980bacd9c5421341c66fabc838ac Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Tue, 30 Mar 2021 09:43:35 +0400 Subject: =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=82=D1=80=D0=B5=D1=82=D1=8C=D1=8E=20=D0=B7=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D1=83=20=D0=B8=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D1=8E=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D1=84=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphs/task1.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'graphs/task1.cpp') diff --git a/graphs/task1.cpp b/graphs/task1.cpp index 62806ae..1fea795 100644 --- a/graphs/task1.cpp +++ b/graphs/task1.cpp @@ -10,11 +10,16 @@ void print(graph g) for (int i = 0; i < int(g.size()); ++i) { cout << i + 1 << ": "; - for (auto node : g[i]) - cout << node + 1 << ", "; - cout << endl; - } + for (int j = 0; j < int(g[i].size()) - 1; ++j) + cout << g[i][j] + 1 << ", "; + + if (g[i].size() > 0) + cout << g[i].back() + 1; + else + cout << "нет смежных вершин"; + cout << ";" << endl; + } } int main() -- cgit v1.2.3