67行一下就打印不出来了不知道为什么?
源代码:
#include"stdio.h"
#include"malloc.h"
typedef struct Node
{
int data;
struct Node* next;
}Node;
Node* create(Node* L, int n)
{
int x, i;
Node* h = NULL, * s = NULL;
h = (Node*)malloc(sizeof(Node));
L = h;
printf("请输入第1个数据:");
scanf_s("%d", &x);
h->data = x;
for (i = 2; i <= n; i++)
{
printf("请输入第%d个数据:",i);
scanf_s("%d", &x);
s = (Node*)malloc(sizeof(Node));
s->data = x;
h->next = s;
h = s;
}
h = NULL;
return L;
}
void display(Node* L)
{
Node* h;
h = L;
while (h)
{
printf("%d ", h->data);
h = h->next;
}
printf("\n");
}
Node* dele(Node* L)
{
Node* h, * s;
int x,i,j;
h = L;
while (h != NULL)
{
if ((h->data) > (h->next->data))x = h->data;
h = h->next;
}
for (i = 1, h = L; h->data == x; i++)
h = h->next;
for (j = 0, h = L; h->next != NULL && j < i - 1; j++)
h = h->next;
s = h->next;
h->next=h->next->next;
free(s);
return L;
}
void main()
{
Node* List = NULL;
int num;
printf("请输入数据的个数:");
scanf_s("%d", &num);
List = create(List, num);
printf("原数据:");
display(List); printf("删除最大值后:");
/*List=dele(List);
printf("删除最大值后:");
display(List);*/
}
运行结果及报错内容