Title: Enter the information of several students (including school number, name and grade), enter the end of the input number is 0 o'clock. Establish a one-way linked list, and then enter a score value, the result is greater than equal to the value of the student information output.
Input:3n+2 line, every 3 acts a student's information, respectively, is the study number, name and result. The penultimate act of 0 indicates the end of the input. The last behavior is an integer that represents the score.
Output: Several lines, each three lines represent a student's information.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct stud_node{
int long num;
Char name[20];
int score;
struct Stud_node *next;
};
int main ()
{int Size,score;char name[20];int long num;
struct Stud_node *head, *tail,*p,*ptr;
Head = tail = NULL;
size = sizeof (struct stud_node);
scanf ("%ld", &num);
while (num!=0)
{
scanf ("%s%d", Name, &score);
p= (struct Stud_node *) malloc (size);
P->num =num;
strcpy (p->name, name);
P->score = score;
P->next = NULL;
if (head = = NULL)
head = p;
Else
Tail->next = p;
Tail=p;
scanf ("%ld", &num);
}
INTs
scanf ("%d", &s);
printf ("%d", s);
for (Ptr=head;ptr!=null;ptr=ptr->next)
if (Ptr->score >= s)
printf ("%ld\n%s\n%d\n", Ptr->num,ptr->name,ptr->score);
return 0; }