求助......
  • 板块学术版
  • 楼主xinmouren24
  • 当前回复8
  • 已保存回复8
  • 发布时间2021/6/13 08:20
  • 上次更新2023/11/4 21:57:13
查看原帖
求助......
474008
xinmouren24楼主2021/6/13 08:20

这是一串编译错误的代码↓

#include<bits/stdc++.h>
using namespace std;
const int maxn=1005;
int a[maxn];
int main()
{
	stack<int> sta;
	int n,cnt,stanum=0;
	cin>>n;
	int t,lj;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		memset(a,0,sizeof(a));
		for(int j=0;j<t;j++)
		{
			cin>>a[j];
		}
		for(int j=t-1;j>=0;j--)
		{
			stanum=0;
			cnt=0; 
			if(j==t-1)
			{
				sta.push(a[j]);
				continue;
			}
			for(int k=j+1;k<t;k++)
			{
				if(a[j]==a[k])
				{
					cnt++;
					break;
				} 
			}
			if(cnt==0)
			{
				sta.push(a[j]);
			}
			stanum=sta.size();
			for(int j=0;j<stanum;j++)
			{
				cout<<sta[j]<<" ";
			}
			while(!sta.empty())
			{
				sta.pop();
			}
		}
	}
}

错误提示在第43行

有没有大佬能帮我解决咩

2021/6/13 08:20
加载中...