#include
Struct student
{
Char name [10].
Int result;//the final average score
Int review;//class assessment score
Char bo;//whether the western student
Int papnum;//paper number
Struct student * next;
} Mystu;
int n;
Struct student * input ()
{
int i;
Struct student * head=NULL, * p=NULL, * q=NULL;
For (I=0; i
q=p;//save before an element address will address assigned to q p
P=(struct student *) malloc (sizeof (struct student));
Printf (" % d student information (include: name your final course grade class evaluation whether the western student papers) \ n ", I + 1);
The scanf (" % s % d % d % d % d ", & amp; P - & gt; The name, & amp; P - & gt; The result, & amp; P - & gt; Review, & amp; P - & gt; Bo, & amp; P - & gt; Papnum);
P - & gt; Next=NULL;
If (head==NULL)
The head=p;
The else
Q - & gt; Next=p;
}
return head;
}
Void the output (struct student * head)
{
Struct student * p=NULL;
P=the head;
While (p!=NULL)
{
Printf (" % s % d % d % d % s \ n ", p - & gt; The name, p - & gt; The result of p - & gt; Review, p - & gt; Bo, p - & gt; Papnum);
Printf (" % s \ n ", p - & gt; Name);
Printf (" % d \ n ", p - & gt; The result);
Printf (" % d \ n ", p - & gt; Review);
Printf (" % s \ n ", p - & gt; Bo);
Printf (" % d \ n ", p - & gt; Papnum);
P=p - & gt; next;
}
}
Int main ()
{
Struct student * head=NULL;
Printf (" do input student number (n) : \ n ");
The scanf (" % d ", & amp; N);
The head=input ();
Printf (" main: % p \ n ", the head);
The output (the head);
return 0;
}
CodePudding user response:
Your structure is this statement thechar bo;//whether the western students, but your input is such input
the scanf (" % s % d % d % d % d ", & amp; P - & gt; The name, & amp; P - & gt; The result, & amp; P - & gt; Review, & amp; P - & gt; Bo, & amp; P - & gt; Papnum);but you print was so printed
printf (" % s % d % d % d % s \ n ", p - & gt; The name, p - & gt; The result of p - & gt; Review, p - & gt; Bo, p - & gt; Papnum); [code=c] printf (" % s \ n ", p - & gt; Bo);think the bo is int the hell are you? Char? The string? I don't know!
CodePudding user response:
the scanf (" % s % d % d % d % d ", & amp; P - & gt; The name, & amp; P - & gt; The result, & amp; P - & gt; Review, & amp; P - & gt; Bo, & amp; P - & gt; Papnum);
Input format and its data type mismatch, and since the name is a string, the input need not add & amp; That changed this to say again first