#include <iostream> #include <vector> #include <iterator> #include <algorithm> using namespace std; int main(){ vector<int> a; int n, t; cin >> n >> t; std::copy(std::istream_iterator<int>(cin), std::istream_iterator<int>(), std::back_inserter(a)); if(t%2){ std::copy(a.rbegin(), a.rend(), std::ostream_iterator<int>(std::cout, " ")); }else{ std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout, " ")); } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> #include <vector> #include <iterator> #include <algorithm> using namespace std; int main(){ vector<int> a; int n, t; cin >> n >> t; std::copy(std::istream_iterator<int>(cin), std::istream_iterator<int>(), std::back_inserter(a)); if(t%2){ std::copy(a.rbegin(), a.rend(), std::ostream_iterator<int>(std::cout, " ")); }else{ std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout, " ")); } return 0; } |