T211873不会做 求解!
  • 板块学术版
  • 楼主zzhpdyx
  • 当前回复3
  • 已保存回复3
  • 发布时间2025/2/6 20:06
  • 上次更新2025/2/7 00:19:24
查看原帖
T211873不会做 求解!
1456667
zzhpdyx楼主2025/2/6 20:06

以下错误代码:

#include<bits/stdc++.h>
#include<stack>
#include<queue>
using namespace std;   
stack<int> st1,st2,cz,cz1;
int a[100005],n,y,m,w;   
int main()   
{   
    cin>>n>>m;  
	char x; 
   	for(int i=1;i<=n;i++){
   		cin>>x;
   		if(x=='A'){
   			cin>>y;
   			int e=y%m;
   			st1.push(e);
		}
		if(x=='Q')
		{
			cin>>w;
			int sum=st1.top();
			for(int j=1;j<=w;i++){
				st2.push(st1.top());
				if(sum<st1.top()){
					sum=st1.top();
				} 
					
				st1.pop();
				
			}
			for(int j=1;j<=w;i++){
				int z=st2.top();
				st1.push(z);
				st2.pop();
			}
			cz.push(sum);
		}
	}
	while(cz.empty()==0)
	{
		cz1.push(cz.top());
		cz.pop();
	}
	while(cz1.empty()==0)
	{
		cout<<cz1.top()<<endl;
		cz1.pop();
	}
    return 0;   
}
2025/2/6 20:06
加载中...