# 題目 * 設計一個程式,該程式可以連續讀入正整數(輸入0表示結束,至多不超過10個正整數),之後將所輸入的正整數以相反序顯示在畫面上。 # 思路 1. 宣告一個可以允許向前排放的容器, 我是使用 *deque* 。 2. 直接輸入測資依照各個容器的性質。 3. 直接 *for loop* 輸出就結束啦 !! # 注意事項 >數字範圍:整數 1 – 1000 # Code ```C++=1 #include <iostream> #include <deque> int main() { int n; std::deque<int> dq; while(std::cin>>n,n)dq.push_front(n); for(auto i:dq)std::cout<<i<<" "; std::cout<<"\n"; } ```
×
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