2023-10-22 10:46:11
发布于:北京
#include<bits/stdc++.h>
using namespace std;
char s[100],q[100]; //q队列 s接受QQ号
int head=0,tail=0;//队首、队尾
//入队
void push(int x){
tail++;
q[tail]=x;
//q[tail]=x;
}
//出队
void pop(){
head;
}
//取队首
char front(){
return q[head+1];
}
//取队尾
int back(){
return q[tail];
}
//判断队列是否为空
bool empty(){
return headtail;
//return tail-head0;
}
int main(){
cin>>s;
for(int i=0;i<strlen(s);i++){
push(s[i]);
}
while(!empty()){//当队列不为空时
cout<<front();
pop();
push(front());
pop();
}
return 0;
}
这里空空如也
有帮助,赞一个