#include<stdio.h>
#include<stdlib.h>
struct List{
int data;
struct List *next;
};
void set_list(struct List *p,int n){
int i=1;
struct List *p1 = NULL;
p1 = (struct List *)malloc(sizeof(struct List));
p->next = p1;
p1->next = NULL;
scanf("%d",&(p1->data));
while(n-1){
set_list(p1, n-1);
break;
}
}
int main(){
int n,m;
scanf("%d %d",&n,&m);
struct List *head = NULL;
head = (struct List*)malloc(sizeof(struct List));
set_list(head, n);
struct List *p = head;
for(int i=1;i<=m;i++){
p=p->next;
}
struct List *newnode = (struct List*)malloc(sizeof(struct List));//申请新空间
newnode->next = p->next;
p->next = newnode;
newnode->data = m;
p=head->next;
while(p){
printf("%d ",p->data);
p= p->next;
}
return 0;
}
#include<stdlib.h>
struct List{
int data;
struct List *next;
};
void set_list(struct List *p,int n){
int i=1;
struct List *p1 = NULL;
p1 = (struct List *)malloc(sizeof(struct List));
p->next = p1;
p1->next = NULL;
scanf("%d",&(p1->data));
while(n-1){
set_list(p1, n-1);
break;
}
}
int main(){
int n,m;
scanf("%d %d",&n,&m);
struct List *head = NULL;
head = (struct List*)malloc(sizeof(struct List));
set_list(head, n);
struct List *p = head;
for(int i=1;i<=m;i++){
p=p->next;
}
struct List *newnode = (struct List*)malloc(sizeof(struct List));//申请新空间
newnode->next = p->next;
p->next = newnode;
newnode->data = m;
p=head->next;
while(p){
printf("%d ",p->data);
p= p->next;
}
return 0;
}