编辑代码

#include <stdio.h>
#include <malloc.h>
#define LEN sizeof(struct student)

struct student {
    int num;
    float score;
    struct student *next;
};

int main () {
    struct student *head, *p; //定义结构体指针变量
    head = p = (struct student *) malloc(LEN); //开辟一个新单元,head与p都指向它
    scanf("&d %f",&p->num, &p->score);       //输入第一个结点数据
    p = (struct student *) malloc(LEN);     //开辟第二个新单元,p指向它
    scanf("&d %f",&p->num, &p->score);      //输入第二个结点数据
    head->next = p;
    p->next = NULL;

    // p = head;
    // while (p!=NULL)
    // {
    //     printf("%d %4.2f\n",p->num,p->score);
    //     p = p->next;
    // }

    return 0;
}