求解 不懂写出来运行也OK 就是过不了
查看原帖
求解 不懂写出来运行也OK 就是过不了
831297
PalSweet楼主2022/10/26 20:48

#include<bits/stdc++.h>
using namespace std;
const int N = 10e5 + 6;
int t[N];	
void charu(int &a,int &b)
{ 	
for(int i=0;i<N;i++) 
	if(a==t[i])
	{
	int tmp;
	tmp=t[i+1];
	t[i+1]=b;
	b=tmp;	
	break;
	}		
}

void shanchu(int d)
{
for(int i=0;i<N;i++) 
	if(d==t[i])
	{
	  for(int j=i;j<N;j++)
	   t[j+1]=t[j+2];}	
}
int  chazhao(int c)
{
for(int i=0;i<N;i++) 
	if(c==t[i])
	{
	 if(t[i+1]!=NULL)	
	  return t[i+1];
     else 
      return 0;
	}	
}
int main()
{
	t[0]=1;
	int q,n;
	cin>>q;
	for(int i=0;i<q;i++){
	 cin>>n;
	 if(n==1)
	 {
	 int x,y;
	 cin>>x>>y;
	 charu(x,y);
	 }	
    if(n==2)
	{
	int x,sc;
	cin>>x;
	sc=chazhao(x);
	cout<<sc<<endl;
	}
    if(n==3)
	{
	int x;
	cin>>x;
	shanchu(x);
	}}		
}

不懂为什么实例都运行出来了 结果 0

2022/10/26 20:48
加载中...