Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int rand(int a, int b)
  6. {
  7. return a + rand()%(b-a+1);
  8. }
  9. // returns true if more than 3 connections,,binary tree..
  10. bool count_connections(vector <pair <int, int > v, int m)
  11. {
  12. int n = v.size();
  13. int count{0};
  14. for(int i =0 ; i < n ; i++)
  15. {
  16. if(v.at(i).first == m || v.at(i).second == m)
  17. count++;
  18. }
  19. if (count > 3)
  20. return false;
  21. return true;
  22. }
  23.  
  24. int main(int argc, char * argv[])
  25. {
  26. srand(atoi(argv[1]));
  27. vector < pair <int, int> > v;
  28. int n = rand(2, 20);
  29. printf("%dn", n);
  30. for(int i =2; i <= n; ++i)
  31. {
  32. v.push_back(make_pair(rand(1, i-1), i));
  33. if(count_connections(v, i))
  34. printf("%d %dn", rand(1, i-1), i);
  35. }
  36. }
  37.  
  38. ```````
  39. I think it has something to do with use of vector as first argument..I am not sure what.
  40.  
  41. simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
  42. bool count_connections(vector <pair <int, int > &v, int m)
  43. ^
  44. simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
  45. simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
  46. simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
  47. simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
  48. simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
  49. simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
  50. simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
  51. simple_tree_gen.cpp:10:24: error: invalid template-id
  52. bool count_connections(vector <pair <int, int > &v, int m)
  53. ^~~~~~
  54. simple_tree_gen.cpp:10:58: error: missing template arguments before ‘)’ token
  55. bool count_connections(vector <pair <int, int > &v, int m)
  56. ^
  57. simple_tree_gen.cpp: In function ‘int main(int, char**)’:
  58. simple_tree_gen.cpp:33:34: error: ‘count_connections’ cannot be used as a function
  59. if(count_connections(v, i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement