#include<stdio.h>
#include<stdlib.h>
#include<string>
typedef struct node{
int num;
node *next;
}node;
node *Create_stu_Doc(int n){
int num;
int size=sizeof(node);
node *head,*tail,*p;
head=tail=NULL;
for(int i=1;i<=n;i++){
scanf("%d",num);
p=(node*)malloc(size);
p->num=num;
p->next=NULL;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
}
return head;
}
int main (){
int n,m,k=0,j,g=1;
scanf("%d %d",&n,&m);
node *ptr,*ptr1,*head=Create_stu_Doc(n);
for(ptr=head;ptr!=NULL;ptr=ptr->next){
k++;
if(k==(n-m)){
for(ptr;ptr!=NULL;ptr=ptr->next){
j=ptr->num;
g=g*j;
}
break;
}
}
printf("%d",g);
}
以上代码的结果为什么会出错