2018ACM_秋季集训_程序设计基础_2_实验2链表_F节点插入_2874
runtime error
int m, x, k = 0, i;
head = (struct node*)malloc(sizeof(struct node));
head->next = NULL;
tail = head;
while(n--)
{
scanf("%d%d", &m, &x);
struct node *p = (struct node*)malloc(sizeof(struct node));
p->data = x;
struct node *q = head;
while(m--&&q->next)
q = q->next;
p->next = q->next;
q->next = p;
}
ac
int m, x, k = 0, i;
head = (struct node*)malloc(sizeof(struct node));
head->next = NULL;
tail = head;
while(n--)
{
scanf("%d%d", &m, &x);
struct node *p = (struct node*)malloc(sizeof(struct node));
p->data = x;
struct node *q = head;
while(m--&&q->next)
q = q->next;
p->next = q->next;
q->next = p;
}