#include<bits/stdc++.h> using namespace std; struct Edge{ int x; int y; }; vector <Edge> G; //G[i]代表从i出发的边,vector里存的是边 int m,n; int temp; int main(void) { int ne; cin>>n>>m; //Edge e; ne=m; while(ne--) { Edge e; cin>>(e).x>>(e).y; G.push_back(e); } //遍历 for(auto iter =G.cbegin();iter !=G.cend();iter ++) {//iter此时是个指针类型 cout<<iter->x<<"->" <<iter->y<<endl; } return 0; }
原文:https://www.cnblogs.com/ewitt/p/14770813.html