mmpo

|
分享:
▲
▼
送你一個惡搞版的 ^^ #include<iostream> #include<stack>
using namespace std;
int main(void){ stack<int> s; stack<int> b; int i=1,temp; while(i){ cout<<" <1> push \n <2> pop \n <3> list \n <4> quit "<<endl; cin>>i; switch(i){ case 1 : cout<<"press a number"<<endl; cin>>temp; s.push(temp); break; case 2 : if (!s.empty()){ temp=s.top(); s.pop(); cout<<"stack pop "<<temp<<endl; } else cout<<"stack empty"<<endl; break; case 3 : while(!s.empty()){ b.push(s.top()); s.pop(); } while(!b.empty()){ cout<<b.top()<<endl; b.pop(); } break; case 4 : i=0; break; } } system("pause"); }
若是這樣也行,再附上第二題的惡搞版
|