题解
2024-08-17 09:49:30
发布于:吉林
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct node{
int data;
node *next;
}*head,*r,*p;
int a;
int main(){
cin>>a;
head=new node;
r=head;
for(int i=1;i<=a;i++){
p=new node;
cin>>p->data;
p->next=NULL;
r->next=p;
r=p;
}
p=head->next;
int x,y;
cin>>x>>y;
node *s;
s=new node;
s->data=y;
while(p->next!=NULL&&p->data!=x)p=p->next;
s->next=p->next;
p->next=s;
p=head->next;
while(p->next!=NULL){
cout<<p->data<<' ';
p=p->next;
}
cout<<p->data<<' ';
return 0;
}
这里空空如也
有帮助,赞一个