auto and ranges based loop
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v={1,2,3,4,5,1};
for(auto u:v)
{
cout<<u<<" ";
}
cout<<endl;
vector<pair<int,int>> vp={{1,2},{3,4},{5,1}};
for(auto u : vp) cout<<u.first<<" "<<u.second<<endl;
return 0;
}
0 Comments