Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int rand(int a, int b)
- {
- return a + rand()%(b-a+1);
- }
- // returns true if more than 3 connections,,binary tree..
- bool count_connections(vector <pair <int, int > v, int m)
- {
- int n = v.size();
- int count{0};
- for(int i =0 ; i < n ; i++)
- {
- if(v.at(i).first == m || v.at(i).second == m)
- count++;
- }
- if (count > 3)
- return false;
- return true;
- }
- int main(int argc, char * argv[])
- {
- srand(atoi(argv[1]));
- vector < pair <int, int> > v;
- int n = rand(2, 20);
- printf("%dn", n);
- for(int i =2; i <= n; ++i)
- {
- v.push_back(make_pair(rand(1, i-1), i));
- if(count_connections(v, i))
- printf("%d %dn", rand(1, i-1), i);
- }
- }
- ```````
- I think it has something to do with use of vector as first argument..I am not sure what.
- simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
- bool count_connections(vector <pair <int, int > &v, int m)
- ^
- simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
- simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
- simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
- simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
- simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
- simple_tree_gen.cpp:10:57: error: template argument 1 is invalid
- simple_tree_gen.cpp:10:57: error: template argument 2 is invalid
- simple_tree_gen.cpp:10:24: error: invalid template-id
- bool count_connections(vector <pair <int, int > &v, int m)
- ^~~~~~
- simple_tree_gen.cpp:10:58: error: missing template arguments before ‘)’ token
- bool count_connections(vector <pair <int, int > &v, int m)
- ^
- simple_tree_gen.cpp: In function ‘int main(int, char**)’:
- simple_tree_gen.cpp:33:34: error: ‘count_connections’ cannot be used as a function
- if(count_connections(v, i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement