Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "iostream"
- #include <conio.h>
- #include <vector>
- #include <queue>
- using namespace std;
- // НИРАБОТАИТ(((((999(((
- void GetGraph(vector<vector<char>> &Graph, int &vertices)
- {
- char ch;
- cout << "Введите число вершин: "; cin >> vertices;
- vector<char> Edges; // ребра
- for (int i = 0; i < vertices; i++)
- {
- cout << "\nВведите, с какими вершинами связана " << char(97 + i) <<": ";
- ch = ' ';
- while (ch != '\r')
- {
- ch = getch();
- if ((ch != ' ') && (ch != ',')) { Edges.push_back(ch); }
- }
- Graph.push_back(Edges);
- Edges.clear();
- }
- cout << endl;
- }
- void ShowGraph(vector<vector<char>> Graph)
- {
- char t = 'a';
- vector<char> Edges;
- for (vector<vector<char>>::iterator i = Graph.begin(); i != Graph.end(); i++)
- {
- cout << "Вершина " << t++ << " связана ребрами с: ";
- Edges = *i;
- for (vector<char>::iterator j = Edges.begin(); j != Edges.end(); j++)
- {
- cout << (*j) << ", ";
- }
- cout << endl;
- }
- }
- void main()
- {
- setlocale(LC_ALL,"RUSSIAN");
- vector<vector<char>> Graph;
- int vertices;
- GetGraph(Graph, vertices);
- ShowGraph(Graph);
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement