Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int main()
- {
- queue <int> podr;
- string s;
- int n;
- cin>> s;
- while (s!="exit")
- {
- if (s=="push")
- {
- cin>>n;
- podr.push(n);
- cout<<"ok"<< endl;
- }
- if (s=="pop")
- {
- if (!podr.empty()) {
- cout<<podr.front()<<endl;
- podr.pop();
- }
- else cout<<"error"<<endl;
- }
- if (s=="front")
- {
- if (!podr.empty()) {
- cout<<podr.front()<<endl;
- }
- else
- cout<<"error"<<endl;
- }
- if (s=="size")
- {
- cout<<podr.size()<<endl;
- }
- if (s=="clear")
- {
- while(!podr.empty())
- {
- podr.pop();
- }
- cout<<"ok"<<endl;
- }
- cin>>s;
- }
- cout<<"bye";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement