#include<bits/stdc++.h>
using namespace std;
void printVec(vector<int> fv){
for(int i=0;i<fv.size();i++){
cout << fv[i] << " ";
}
cout << endl;
}
void print_it_of_vec(vector<int> fv1){
vector<int> ::iterator fit;
for(fit = fv1.begin();fit != fv1.end();++fit){
cout << *fit << " ";
}
cout << endl;
}
/*
ITERATORS: Pointer like structures, helps in accessing
elements of containers(e.g. vector, array, lists, etc)
using indexation just like Pointers are used to indicate
an element in an array. Some iterators are discussed below-
###Syntax : container_name<data_type> ::iterator it_name;
###Purpose : To iterate through a container that doenst
support indexing, unlike vectors.
1.begin(): Points to the first element;
2.end(): Points to the last element.
*/
int main(){
vector<int> v1 = {2,3,5,6,7};
printVec(v1);
vector<int> ::iterator it1 = v1.begin();
cout << "value at iterator " << *it1 << endl;
cout << *(it1 + 1) << endl;
/*for(it1 = v1.begin(); it1 != v1.end();++it1){
cout << (*(it1)) << " ";
}
cout << endl;*/
print_it_of_vec(v1);
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgcHJpbnRWZWModmVjdG9yPGludD4gZnYpewoJZm9yKGludCBpPTA7aTxmdi5zaXplKCk7aSsrKXsKCQljb3V0IDw8IGZ2W2ldIDw8ICIgIjsKCX0KCWNvdXQgPDwgZW5kbDsKfQp2b2lkIHByaW50X2l0X29mX3ZlYyh2ZWN0b3I8aW50PiBmdjEpewoJdmVjdG9yPGludD4gOjppdGVyYXRvciBmaXQ7Cglmb3IoZml0ID0gZnYxLmJlZ2luKCk7Zml0ICE9IGZ2MS5lbmQoKTsrK2ZpdCl7CgkJY291dCA8PCAqZml0IDw8ICIgIjsKCX0KCWNvdXQgPDwgZW5kbDsKfQovKgpJVEVSQVRPUlM6IFBvaW50ZXIgbGlrZSBzdHJ1Y3R1cmVzLCBoZWxwcyBpbiBhY2Nlc3NpbmcgCmVsZW1lbnRzIG9mIGNvbnRhaW5lcnMoZS5nLiB2ZWN0b3IsIGFyc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