Home > Back-end >  Consult bosses
Consult bosses

Time:10-03


why?
# include & lt; stdio.h>
# include & lt; stdlib.h>

Struct node {
The int data;
Struct node * next;
};
Typedef struct node node; NODE * createlistr ()
{int x; Head NODE * and * L * r;
The head=NULL;
R=NULL;
The scanf (" % d ", & amp; X);
while(x!=1)
{
L=(*) malloc (sizeof (NODE));
L - & gt; data=https://bbs.csdn.net/topics/x;
If (head==NULL) head=L;
The else r - & gt; Next=L;
R=L;
The scanf (" % d ", & amp; X);
}
If (r! R=NULL) - & gt; Next=NULL;
Return the head;
}

Int min (NODE * L)
{
The NODE * p, * k;
int x;
K=L;
While (k - & gt; Next!=NULL)
If (k - & gt; Data>=k - & gt; Next - & gt; Data)
{p=k - & gt; Next; K=k - & gt; Next;
}
X=p - & gt; The data;
If (x % 2==1)
{
Delete_ (p);
The return (1);
}
The else
Return (2);
} void delete_ (NODE * p)
{
NODE * q;
Q=p - & gt; Next;
P - & gt; data=https://bbs.csdn.net/topics/p-> next -> data;
P - & gt; Next=q - & gt; Next;
Free (q);
}

Int main ()
{int x; NODE * L;
L=createlistr ();
X=min (L);
Printf (" % d ", x);
}

CodePudding user response:

Function void delete_ (NODE * p) statement is defined after the min function, lead to don't know min delete_

The
Void delete_ (NODE * p)
{
NODE * q;
Q=p - & gt; Next;
P - & gt; data=https://bbs.csdn.net/topics/p-> next -> data;
P - & gt; Next=q - & gt; Next;
Free (q);
}
Move to the top of the min function

Or on the top of the min function to join
Void delete_ (NODE * p);//add function declaration


CodePudding user response:

reference 1st floor qybao response:
function void delete_ (NODE * p) statement is defined after the min function, lead to don't know min delete_

The
Void delete_ (NODE * p)
{
NODE * q;
Q=p - & gt; Next;
P - & gt; data=https://bbs.csdn.net/topics/p-> next -> data;
P - & gt; Next=q - & gt; Next;
Free (q);
}
Move to the top of the min function

Or on the top of the min function to join
Void delete_ (NODE * p);//add function declaration
ok, thank you
  • Related