1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #include <iostream>
#include <set>
#include <vector>
#include <map>
#include <tuple>
using namespace std;
typedef map< int, set< pair<int,int> > > PipeNetwork;
typedef vector< tuple<int, int, int> > InputNetwork;
InputNetwork FillInputNetwork()
{
InputNetwork input_network;
input_network.push_back(make_tuple(1, 2, 3));
input_network.push_back(make_tuple(1, 4, 5));
input_network.push_back(make_tuple(2, 5, 6));
input_network.push_back(make_tuple(3, 4, 5));
input_network.push_back(make_tuple(1, 8, 5));
input_network.push_back(make_tuple(2, 7, 5));
input_network.push_back(make_tuple(1, 8, 5)); // doublon
return input_network;
}
void PrintPipeNetwork(const PipeNetwork& pipes)
{
for (auto p1 : pipes)
{
cout << "pipe " << p1.first << endl;
for (auto p2 : p1.second)
cout << " " << p2.first << " - " << p2.second << endl;
cout << endl;
}
}
int main()
{
InputNetwork input_network = FillInputNetwork();
PipeNetwork pipes;
for (auto t : input_network)
pipes[get<0>(t)].insert(make_pair(get<1>(t),get<2>(t)));
PrintPipeNetwork(pipes);
getchar();
return 0;
} |
Partager