Advertisement
Guest User

Untitled

a guest
Jan 7th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include <conio.h>
  4. #include <vector>
  5. #include <queue>
  6. using namespace std;
  7.  
  8. // НИРАБОТАИТ(((((999(((
  9. void GetGraph(vector<vector<char>> &Graph, int &vertices)
  10. {
  11. char ch;
  12. cout << "Введите число вершин: "; cin >> vertices;
  13. vector<char> Edges; // ребра
  14. for (int i = 0; i < vertices; i++)
  15. {
  16. cout << "\nВведите, с какими вершинами связана " << char(97 + i) <<": ";
  17. ch = ' ';
  18. while (ch != '\r')
  19. {
  20. ch = getch();
  21. if ((ch != ' ') && (ch != ',')) { Edges.push_back(ch); }
  22. }
  23. Graph.push_back(Edges);
  24. Edges.clear();
  25. }
  26. cout << endl;
  27. }
  28.  
  29. void ShowGraph(vector<vector<char>> Graph)
  30. {
  31. char t = 'a';
  32. vector<char> Edges;
  33. for (vector<vector<char>>::iterator i = Graph.begin(); i != Graph.end(); i++)
  34. {
  35. cout << "Вершина " << t++ << " связана ребрами с: ";
  36. Edges = *i;
  37. for (vector<char>::iterator j = Edges.begin(); j != Edges.end(); j++)
  38. {
  39. cout << (*j) << ", ";
  40. }
  41. cout << endl;
  42. }
  43. }
  44.  
  45.  
  46. void main()
  47. {
  48. setlocale(LC_ALL,"RUSSIAN");
  49. vector<vector<char>> Graph;
  50. int vertices;
  51. GetGraph(Graph, vertices);
  52. ShowGraph(Graph);
  53. _getch();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement