题解 | #Zero-complexity
Zero-complexity Transposition
https://www.nowcoder.com/practice/c54775799f634c72b447ef31eb36e975
#include "cstdio" #include "stack" #include "vector" #include "queue" #include "algorithm" using namespace std; bool comp_(int a, int b) { return true; } // 用栈来解决 int main() { int n; scanf("%d", &n); stack<int> stack; int temp; for (int i = 0; i < n; ++i) { scanf("%d", &temp); stack.push(temp); } while (!stack.empty()) { printf("%d ", stack.top()); stack.pop(); } return 0; } void test2() { int n; scanf("%d", &n); vector<int> vec; int temp; for (int i = 0; i < n; ++i) { scanf("%d", &temp); vec.push_back(temp); } // printf("size=%d\n", vec.size()); for (int i = n - 1; i >= 0; --i) { vec.pop_back(); printf("%d ", vec[i]); } // printf("\nsize=%d", vec.size()); } /* int n; scanf("%d", &n); long long int arr[n]; for (int i = 0; i < n; ++i) { scanf("%d", &arr[i]); } for (int i = n - 1; i >= 0; --i) { printf("%d ", arr[i]); } */