读入tm都有问题,数读不进去
  • 板块学术版
  • 楼主go_your_a_head
  • 当前回复4
  • 已保存回复4
  • 发布时间2025/2/2 17:23
  • 上次更新2025/2/2 22:27:10
查看原帖
读入tm都有问题,数读不进去
1558515
go_your_a_head楼主2025/2/2 17:23

B3631, 不求大家调我的代码,只求让大家让我的代码可以读入

#include<bits/stdc++.h>
using namespace std;
struct Node{
	int value;
	Node *next; 
}*head;
void Insert(Node x,Node y){
	for(Node *t=head;t;t=t->next){
		if(t->value==x.value){
			y.next=t->next;
			t->next=&y;
			break;
		}
	}
}//插入 
void Inquiry(Node x){
	for(Node *t=head;t;t=t->next){
		if(t->value==x.value){
			if(t->next==NULL){
				printf("0\n");
				break;
			}
			else{
				t=t->next;
				printf("%d\n",t->value);
				break;
			}
		}
	}
}//询问 
void expurgate(Node x){
	for(Node *t=head;t;t=t->next){
		if(t->value==x.value){
			Node *p=t->next;
			t->next=p->next;
			p->next=NULL;
			break;
		}
	}
}//删除 
int main(){
	int q;
	scanf("%d",&q);
	head=new Node;
	head->value=1;
	for(int i=1;i<=q;i++){
		int a;
		scanf("%d",&a);
		Node x,y;
		if(a==1){
			scanf("%d%d",&x.value,&y.value);
			Insert(x,y);
		}
		else
			if(a==2){
				scanf("%d",&x.value);
				Inquiry(x);
			}
			else{
				scanf("%d",&x.value);
				expurgate(x);
			}
	}
	return 0;
}

通过一位大佬的检查知道了问题在Insert函数

求各位大佬帮我把代码调到能读入,其他的都不用了,谢谢各位大佬

2025/2/2 17:23
加载中...