求助!!!
查看原帖
求助!!!
1306361
Xzm0819楼主2024/7/19 14:38
#include<bits/stdc++.h>
using namespace std;

typedef struct tab{
	int data;
	tab *next;
}tap;
tab *cs(){
	tab *p=new tab;
	p->data=1;
	p->next=NULL;
	return p;
}
tab *p=cs();
int a[100000]={},num=0;
void cr(){
	int x,y;
	cin>>x>>y;
	tab *temp=p;
	while(temp->data!=x)temp->next;
	tab *s=new tab;
	s->next=temp->next;
	temp->next=s;
	s->data=y;
}
void cx(){
	int x;
	cin>>x;
	tab *temp=p;
	while(temp->data!=x)temp->next;
	a[num]=temp->next==NULL?0:temp->next->data;
}
void sc(){
	int x;
	cin>>x;
	tab *temp=p;
	while(temp->data!=x)temp->next;
	tab *d=temp->next;
	temp->next=d->next;
	delete(d);
}

int main(){
	int q;
	cin>>q;
	while(q--){
		int bb;
		cin>>bb;
		
		if(bb==1)cr();
		else if(bb==2)cx();
		else sc();	
	}
	for(int i=0;i<num;i++){
		cout<<a[i]<<"\n";
	}
	return 0;
}

为什么只能输入q个数?

2024/7/19 14:38
加载中...