Student structure Linked list

Source: Internet
Author: User
Tags strcmp

#include <stdio.h>
#include <string.h>
struct Node {
	char num[50];
	Char name[50];
	int grade;
	Node *next;
};
Node a[1000];
int main ()
{
	node *p;
	p=&a[0];
	int i=0;
	while (~SCANF ("%s%s%d", A[i].num,a[i].name,&a[i].grade))
	{
		if (strcmp (A[i].num, "0") ==0&& strcmp (A[i].name, "0") ==0&&a[i].grade==0) break;
		a[i].next=&a[i+1];
		A[i+1].next=null;
		i++;
	}
	while (P->next!=null)
	{
		printf ("%s%s%d\n", P->num,p->name,p->grade);
		p=p->next;
	}
	return 0;
 } 

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

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

Output from the linked list header to the table bit in turn. Output

1 2 3 4 5 6 C1001 Li M1002 He E1003 Xie, M1004 Wu, E1005 Bao 80 0 0 0
Sample Input
1 2 3 4 5 C1001 Li M1002 He E1003 Xie M1004 Wu 80 E1005 Bao /td>

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.