Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <map>
  2. #include <vector>
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <fstream>
  6. #include <sstream>
  7.  
  8. using namespace std;
  9.  
  10. void displayGraph(map<int, vector<int>> map) {
  11. // Hér þarf að útfæra útskriftarfallið, sjá verkefnislýsingu
  12. auto element = map.begin();
  13. cout << element ->first;
  14. }
  15.  
  16. int main() {
  17.  
  18. vector<string> vigur;
  19. string line;
  20. ifstream myfile ("t.txt");
  21. if (myfile.is_open())
  22. {
  23. while ( getline (myfile,line) )
  24. {
  25. vigur.push_back(line);
  26. }
  27. myfile.close();
  28. }
  29.  
  30. else cout << "Unable to open file";
  31.  
  32.  
  33.  
  34. int V, E; // The number of vertices V, the number of edges E
  35. stringstream(vigur[0]) >> V;
  36. stringstream(vigur[1]) >> E;
  37. // Hér þarf að upphafsstilla tilvik af map klasanum
  38.  
  39.  
  40. map<int, vector<int>> mittMap;
  41.  
  42. //búum til V marga hnúta í map
  43.  
  44.  
  45. cout << "hallo";
  46.  
  47. //
  48. int v, w;
  49. // while (scanf("%d %d", &v, &w) != -1) {
  50. for(int i=0; i<22; i++){
  51. // Inni í þessari lykkju eru v og w heiltölur sem nota má til að fylla inn í netið
  52. mittMap[v].push_back(w);
  53.  
  54. }
  55. cout << mittMap.size() << endl;
  56.  
  57. // Hér þarf að kalla á útskriftarfallið
  58.  
  59. displayGraph(mittMap);
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement