diff options
Diffstat (limited to 'graphs/task2.cpp')
| -rw-r--r-- | graphs/task2.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/graphs/task2.cpp b/graphs/task2.cpp index 17dcdbe..0213be0 100644 --- a/graphs/task2.cpp +++ b/graphs/task2.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() |