#include<stdio.h> #include<stdlib.h> #include<assert.h> typedef struct node { int nval; struct node* next; }node; node* creat(int x) { node* head = (node*)malloc(sizeof(node)); assert(head); head->next = NULL; head->nval = 0; node* p = head; for (int i = 0; i < x; i++) { int n; scanf("%d", &n); node* newNode = (node*)malloc(sizeof(node)); assert(newNode); newNode->nval = n; newNode->next = NULL; p->next = newNode; p = p->next; } return head->next; } void insertnode(node* p, int n) { node* p1 = p; for (int i = 1; i < n; i++) { p1 = p1->next; } node* newNode = (node*)malloc(sizeof(node)); newNode->nval = n; newNode->next = NULL; newNode->next = p1->next; p1->next = newNode; } int main() { int m, n; scanf("%d %d", &m, &n); node* head1 = creat(m); insertnode(head1, n); node* head2 = head1; while (head2 != NULL) { printf("%d ", head2->nval); head2 = head2->next; } return 0; }