请你实现一个队列。 操作: push x:将 加入队尾,保证 为 int 型整数。 pop:输出队首,并让队首出队 front:输出队首:队首不出队

区块链毕设网qklbishe.com为您提供问题的解答

请你实现一个队列。
操作:
push x:将 请你实现一个队列。    操作:    push x:将 加入队尾,保证 为 int 型整数。      pop:输出队首,并让队首出队    front:输出队首:队首不出队加入队尾,保证 请你实现一个队列。    操作:    push x:将 加入队尾,保证 为 int 型整数。      pop:输出队首,并让队首出队    front:输出队首:队首不出队为 int 型整数。
pop:输出队首,并让队首出队
front:输出队首:队首不出队

num=input()
l=list()
for _ in range(int(num)):
    a=input()
    if a.split()[0]==’push’:
       l.insert(0, a.split()[1])
    elif a == ‘pop’:
       if not l:
          print(‘error’)
       else:
          print(l.pop())
    elif a == ‘front’:
        if not l:
            print(‘error’)
        else:
            print(l[-1])
        
47:13

#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int q[N]; int n, x; int front = -1, back = -1; string s; int main() {     cin>>n;     while (n--) {         cin>>s;         if (s == "push") {             cin>>x;             q[++back] = x;         } else if (s == "pop") {             if (front >= back) {                 cout<<"error"<<endl;             } else {                  cout<<q[++front]<<endl;             }         } else if (s == "front") {             if (front >= back) {                 cout<<"error"<<endl;             } else {                 cout<<q[front+1]<<endl;             }         }     }      return 0; }

17:29

以上就是关于问题请你实现一个队列。 操作: push x:将 加入队尾,保证 为 int 型整数。
pop:输出队首,并让队首出队 front:输出队首:队首不出队的答案

欢迎关注区块链毕设网-
专业区块链毕业设计成品源码,定制。

区块链NFT链游项目方科学家脚本开发培训

承接区块链项目定制开发

微信:btc9767

QQ :1330797917

TELEGRAM: BTCOK9

承接区块链项目定制开发


qklbishe.com区块链毕设代做网专注|以太坊fabric-计算机|java|毕业设计|代做平台-javagopython毕设 » 请你实现一个队列。 操作: push x:将 加入队尾,保证 为 int 型整数。 pop:输出队首,并让队首出队 front:输出队首:队首不出队