|   | #2wufuzhang2019-07-31 09:43 回复 楼主 F3268724562 | 
    #include <stdio.h>
#include <stdlib.h>
typedef struct STUDENTINF
{
    char name[20];
    float score;
    struct STUDENTINF *next;
}stu;
//创建链表;
struct stu* creat(int n)
{
    int i;
    stu* head;
    stu* note;
    stu* end;
    head=(stu*)malloc(sizeof(stu));
    head=end=NULL;    
    for(i=1;i<n;i++)
    {
        note=(stu*)malloc(sizeof(stu));
        printf("请输入学生的姓名\n");
        scanf("%s",note->name);
        printf("请输入学生的成绩\n");
        scanf("%d",¬e->score);
        end->next=note;
        end=note;
    }
    end->next=NULL;
    return head;     
}
//遍历链表;
void output(stu *head)
{
    stu* note;
    note=head;
    while(note->next!=NULL)
    {
        printf("姓名:%s\n",note->name);
        printf("成绩:%d\n",note->score);
        note=note->next;
    }
    return ;
}
int main()
{   
    struct stu* creat(int n);
    void output(stu *head);
    stu* head;
    int n;
    printf("请输入创建链表的个数\n");
    scanf("%d",&n);
    head=creat(n);
    output(head);
    return 0;
}
  

 程序代码:
程序代码: