我正在尝试创建存储在向量内的图形边缘的组合。我还需要生成并将生成的向量存储在向量中。以下是我到目前为止所做的,但目前尚未编译;
#include <stdlib.h>
#include<iostream>
#include<vector>
#include<algorithm>
struct edge{
int a;
int b;
int weight;
edge(int u,int v,int cost)
{
a=u;
b=v;
weight=cost;
}
};
int main()
{
typedef std::vector<edge> V; //<or_any_class>
V v;
v.push_back(1,2,10);
v.push_back(1,3,10);
v.push_back(1,4,10);
v.push_back(3,4,10);
v.push_back(3,5,10);
v.push_back(3,5,10);
do{
std::cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[4]<<std::endl;
}
while(std::next_permutation(v.begin(),v.end()));
return 0;
}
What Im trying to get as output;
1 2
1 3
1 4
3 4
3 5
4 3
1 2 1 3
1 2 1 4
有什么提示吗?