#include "stdio.h"
#include "stdlib.h"
struct stu
{
int index;
float score;
struct stu *next;
};
void CreateList(struct stu *head)
{
struct stu *temp=head; //将头指针赋给一个临时变量
int i=1;
printf("请输入5位学生的成绩:\n");
while(i<=5)
{
struct stu *newNode=(struct stu*)malloc(sizeof(struct stu)); //为新结点分配空间
newNode->next=NULL; //新节点next域赋值为NULL
newNode->index=i++; //为新结点赋值
scanf("%f",&newNode->score);
temp->next=newNode; //将新结点连到链表末尾
temp=newNode; //修改临时指针指向新结点
}
}
void main()
{
struct stu *head;
head=(struct stu*)malloc(sizeof(struct stu)); //为头结点分配空间
head->next=NULL; //头节点next域赋值为NULL
CreateList(head);
}
谁能给我讲讲中间函数 具体是怎么运行的啊
#include "stdlib.h"
struct stu
{
int index;
float score;
struct stu *next;
};
void CreateList(struct stu *head)
{
struct stu *temp=head; //将头指针赋给一个临时变量
int i=1;
printf("请输入5位学生的成绩:\n");
while(i<=5)
{
struct stu *newNode=(struct stu*)malloc(sizeof(struct stu)); //为新结点分配空间
newNode->next=NULL; //新节点next域赋值为NULL
newNode->index=i++; //为新结点赋值
scanf("%f",&newNode->score);
temp->next=newNode; //将新结点连到链表末尾
temp=newNode; //修改临时指针指向新结点
}
}
void main()
{
struct stu *head;
head=(struct stu*)malloc(sizeof(struct stu)); //为头结点分配空间
head->next=NULL; //头节点next域赋值为NULL
CreateList(head);
}
谁能给我讲讲中间函数 具体是怎么运行的啊
