#include<stdio.h>
struct s
{
char name[20];
int num;
struct s *next;
};
int i;
struct s *creat(int n)
{
struct s a[100];
struct s *head;
for(i=0; i<n; i++)
{
printf("Name %d: ", i+1);
getchar();
gets(a[i].name);
printf("Num %d: ", i+1);
scanf("%d", &a[i].num);
printf("\n");
}
head = &a[0];
for(i=0; i<n-1; i++)
{
a[i].next = &a[i+1];
}
a[n].next = NULL;
return head;
}
void output(struct s *head, int n)
{
printf(" Output the student information\n");
for(i=0; i<n; i++)
{
printf("\nName %d: %s\n", i+1, head->name);
printf("Num %d: %d\n", i+1, head->num);
head = head->next;
}
}
int main()
{
struct s *head;
int n;
printf(" Please input the student information number: ");
scanf("%d", &n);
head = creat(n);
output(head, n);
return 0;
}