#include <bits/stdc++.h>
using namespace std;
int main() {
array<int, 5> arr = {1, 3, 4, 5, 6};
for(auto it = arr.begin(); it!=arr.end(); it++) {
cout << *it << " ";
}
cout << endl;
for(auto it = arr.rbegin(); it != arr.rend(); it++) {
cout << *it << " ";
}
cout << endl;
for(auto it = arr.end() - 1; it >= arr.begin(); it--) {
cout << *it << " ";
}
cout << endl;
// for each loop
for(auto it: arr) {
cout << it << " ";
}
cout << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWFycmF5PGludCwgNT4gYXJyID0gezEsIDMsIDQsIDUsIDZ9OyAKCQoJZm9yKGF1dG8gaXQgPSBhcnIuYmVnaW4oKTsgaXQhPWFyci5lbmQoKTsgaXQrKykgewoJCWNvdXQgPDwgKml0IDw8ICIgIjsgCgl9Cgljb3V0IDw8IGVuZGw7CgoKCglmb3IoYXV0byBpdCA9IGFyci5yYmVnaW4oKTsgaXQgIT0gYXJyLnJlbmQoKTsgaXQrKykgewoJCWNvdXQgPDwgKml0IDw8ICIgIjsgCgl9Cgljb3V0IDw8IGVuZGw7CgoJZm9yKGF1dG8gaXQgPSBhcnIuZW5kKCkgLSAxOyBpdCA+PSBhcnIuYmVnaW4oKTsgaXQtLSkgewoJCWNvdXQgPDwgKml0IDw8ICIgIjsgCgl9Cgljb3V0IDw8IGVuZGw7CgoJLy8gZm9yIGVhY2ggbG9vcCAKCWZvcihhdXRvIGl0OiBhcnIpIHsKCQljb3V0IDw8IGl0IDw8ICIgIjsgCgl9Cgljb3V0IDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==