C Language: Swust OJ, program Design C experiment six structural body topic three student structure list (0068)

Source: Internet
Author: User

Description:

Build student information with structure, student information including number, name, score, build a chain of n students
Table and outputs the linked list.

Input:

Enter student information at a time including number, name. 0 0 0 End the program.

Sample Input:

C1001 Li 70m1002 He 89E1003 Xie 83m1004 Wu 92E1005 Bao Sample output:c1001 Li 70m1002 He 89E1003 Xie 83m1004 Wu 92E1005 Bao 80
1#include <stdio.h>2#include <stdlib.h>3 structStudent4 {5     Charnum[ -];6     Charname[ -];7     floatscore;8     structStudent *Next;9 };Ten intN; One structStudent *creat () A { -     structStudent *head,*p1,*P2; -n=0; theP1=p2= (structStudent *) malloc (sizeof(structstudent)); -scanf"%s%s%f",p1->num,p1->name,&p1->score); -Head=NULL; -      while(p1->num!=0&&p1->name!=0&&p1->score!=0) +     { -n+=1; +         if(n==1) AHead=P1; at         Else -p2->next=P1; -P2=P1; -P1= (structStudent *) malloc (sizeof(structstudent)); -scanf"%s%s%f",p1->num,p1->name,&p1->score); -     } inp2->next=NULL; -     returnhead; to } + voidPrintstructStudent *head) - { the     structStudent *p; *p=head; $     if(head!=NULL)Panax Notoginseng     { -          Do  the         { +printf"%s%s%g\n",p->num,p->name,p->score); AP=p->Next; the} while(p!=NULL); +     } - } $ intMain () $ { -     structStudent *head; -Head=creat (); the print (head); -     return 0;Wuyi}

C Language: Swust OJ, program Design C experiment six structural body topic three student structure list (0068)

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.