# include
# define L sizeof (struct employee)
Struct the employee {
Int id;
Char name [20].
Int salary;
Struct the employee * next; };
Struct the employee * creat (void);
Void print (struct the employee * head);
Struct the employee * h (struct the employee * e1, struct the employee * e2);
int n;
Int main () {
Struct the employee * e1, e2,
E1=creat ();
E2=(struct the employee *) malloc (L); The scanf (" % d % d % s ", & amp; E2 - & gt; Id, e2 - & gt; The name, & amp; E2 - & gt; Salary); E2 - & gt; Next=NULL;
Printf (" the all employee information: \ n "); Print (h (e1 and e2)); }
Struct the employee * creat (void) {
Head, struct the employee * * p1, * p;
n=0;
P=(struct the employee *) malloc (L); The scanf (" % d % d % s ", & amp; P - & gt; Id, p - & gt; The name, & amp; P - & gt; Salary); While ((p - & gt; Salary)!={
(1))N=n + 1;
If (n==1) head=p;
The else p1 - & gt; Next=p;
P1=p;
P=(struct the employee *) malloc (L); The scanf (" % d % d % s ", & amp; P - & gt; Id, p - & gt; The name, & amp; P - & gt; Salary); P1} - & gt; Next=NULL;
Free (p);
return(head); }
Void print (struct the employee * head) {
Struct the employee * t;
T=head;
Do {printf (" % d % d % s \ n ", t - & gt; Id, t - & gt; The name, t - & gt; Salary); T=t - & gt; Next; } while (t!=NULL); }
Struct the employee * h (struct the employee * e1, struct the employee * e2) {
Q, struct the employee * * o; O=NULL;
Q=e1;
While (q!=NULL) {
If ((e2 - & gt; Salary) & gt; (q - & gt; Salary)) {
O=q;
Q=q - & gt; Next; }
The else
break; }
If (o==NULL) {
E2 - & gt; Next=e1;
Return (e2); }
The else {o - & gt; Next=e2; E2 - & gt; Next=q; Return (e1); }}
CodePudding user response:
The error C4703: using an uninitialized pointer variable local may have "head"The error C4703: using an uninitialized pointer variable local may have "p1"
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html