# f345: 新手練習題—陣列 ## 題目: 給你一堆數字,只要將它們的順序倒過來輸出就可以了。 ## 測資說明: 每個測資點僅單筆輸入。 第一行有一個正整數N,表示接下來有N個數字。(N<=10^6) 第二行有N個數字Pi。(Pi的大小在int變數型別的範圍內,也就是-2147483648~2147483647) 請將輸入的N個數字順序顛倒後輸出並以空白隔開。 ## C++ Code: ```cpp=1 #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N = 0, tmp = 0; vector<int> v_num; cin >> N; for (int i = 0; i < N; i++) { cin >> tmp; v_num.push_back(tmp); } reverse(v_num.begin(), v_num.end()); for (auto iter : v_num) { cout << iter << " "; } return 0; } ``` --- - [Zerojudge題目連結](https://zerojudge.tw/ShowProblem?problemid=f345) ###### tags: `APCS` `C++`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up