#include <iostream> #include <vector> int card_number(int a, int t) { if(t == 1) { return a; } else { a = a * 2; t = t - 1; return card_number(a, t); } } int main() { int n; int t; std::vector<int> numbers; scanf("%d", &n); scanf("%d", &t); int temp; int cards = card_number(2, n); for(int i = 0; i < cards; i++) { scanf("%d", &temp); numbers.push_back(temp); } if(t % 2 == 0) { for(std::vector<int>::iterator it = numbers.begin(); it != numbers.end(); it++) { std::cout << *it << " "; } } else { for(std::vector<int>::iterator it = numbers.end()-1; it >= numbers.begin(); it--) { std::cout << *it << " "; } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <iostream> #include <vector> int card_number(int a, int t) { if(t == 1) { return a; } else { a = a * 2; t = t - 1; return card_number(a, t); } } int main() { int n; int t; std::vector<int> numbers; scanf("%d", &n); scanf("%d", &t); int temp; int cards = card_number(2, n); for(int i = 0; i < cards; i++) { scanf("%d", &temp); numbers.push_back(temp); } if(t % 2 == 0) { for(std::vector<int>::iterator it = numbers.begin(); it != numbers.end(); it++) { std::cout << *it << " "; } } else { for(std::vector<int>::iterator it = numbers.end()-1; it >= numbers.begin(); it--) { std::cout << *it << " "; } } } |