#include <stdio.h>
#include <stdlib.h>
int n;
typedef struct LNode
{
int data;
struct LNode* next;
}LNode;
void initLinkList(LNode* pL)
{
int i = 0;
LNode* pR, * pS;
scanf("%d", &n);
pR = pL;
for (i = 0; i < n; i++)
{
pS = (LNode*)malloc(sizeof(LNode));
pS->next = NULL;
scanf("%d", &pS->data);
pR->next = pS;
pR = pS;
}
}
int opLinkList(LNode* pL)
{
int i, x, j = 0, e, flag = 1;
LNode* pR, * pS;
pR = pL;
scanf("%d", &i);
scanf("%d", &x);
if (i < 1 || i > n)
{
flag = 0;
return flag;
}
while (j < i - 1 && pR != NULL)
{
j++;
pR = pR->next;
}
if (pR == NULL)
flag = 0;
else
{
pS = (LNode*)malloc(sizeof(LNode));
pS->data = x;
pS->next = pR->next;
pR->next = pS;
}
return flag;
}
void dispLinkList(LNode* pL)
{
LNode* pR;
pR = pL->next;
while (pR != NULL)
{
printf("%d ", pR->data);
pR = pR->next;
}
}
int main()
{
LNode* pL;
pL = (LNode*)malloc(sizeof(LNode));
pL->next = NULL;
initLinkList(pL);
if (opLinkList(pL) == 1)
dispLinkList(pL);
else
printf("error!");
return 0;
}