每次对拍写树总是很麻烦,这里直接弄了个生成器,随机效果一般,但也能凑合用吧(大概
const int maxn = 25; int e[maxn][maxn]; void make_Tree(int n){ memset(e, 0, sizeof e); vector<int> vec1; vector<int> vec2; for (int i = 2; i <= n; i++) { vec1.push_back(i); } vec2.push_back(1); for (int _ = 1; _ < n; _++) { int x = rand() % vec1.size(), y = rand() % vec2.size(); int u = vec1[x], v = vec2[y]; vec2.push_back(u); vec1.erase(vec1.begin() + x); cout << u << " " << v << endl; e[u][v] = e[v][u] = 1; } }
标签:int,生成器,memset,Tree,vector,maxn From: https://www.cnblogs.com/molarsu/p/17056407.html