×
解除綁定,重新設定系統帳號的密碼
您的系統帳號 ID:
您的系統帳號:
您的帳號暱稱:
設定新密碼:
設定新密碼:
×
請輸入要加入的「課程代碼」
請向開設課程的使用者索取「課程代碼」
Problems
Submissions
Rank
Forum
Contest
Login
Register
New Thread
#55451: c++
61247091s@gapps.ntnu.edu.tw
(wei)
School:
No School
ID:
244449
×
傳送站內訊息
To:
Subject:
Content:
IP address:
[123.192.182.169]
註冊時間:
2023-09-07 14:39:22
Last Login:
2025-11-28 22:26:54
i213.
stack 練習
| From: [123.192.179.85] | Post Date: 2026-07-08 21:35
#include <bits/stdc++.h>
using namespace std;
int main(){
int t,move;
cin>>t;
stack <int> s;
while(t--){
cin>>move;
if(move==3){if(s.empty())continue;s.pop();}
else if(move==2){if(s.empty()){cout<<"-1"<<endl;continue;}cout<<s.top()<<endl;}
else if(move==1){cin>>move;s.push(move);}
}
return 0;
}