29. 에지리스트 구현

C++ STL 2025. 4. 23. 15:25

 

//에지리스트 구현
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

typedef tuple<int, int, int> edge;
vector<edge> mlist;

int main()
{
	int i, j, a, b, c;
	int start, end, time;
	int V, E;
	
	cin >> V >> E;   //정점, 에지
	
	for(i=0;i<E;i++)
	{
		cin >> start >> end >> time;
		mlist.push_back(make_tuple(start, end, time));
	}
	
	for(i=0;i<mlist.size();i++)
	{	
		//tie(a, b, c) = mlist[i];	
		edge temp = mlist[i];
		a = get<0>(temp);
		b = get<1>(temp);
		c = get<2>(temp);
		cout << '(' <<  a << ' '<< b << ' ' << c <<')' ;
	}
		
	return 0;	
 }
Posted by 명문코딩컴퓨터
,