C-language linked list __c language

Source: Internet
Author: User

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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.