网友您好, 请在下方输入框内输入要搜索的题目:
void CreateList(struct stu *head){ struct stu=NULL; struct stu *temp=head; int i=1; printf("请输入5位学生的成绩;"); while(i<=5) { struct stu *newNode=(struct stu*)malloc(sizeof(struct stu)); newNode->next=NULL; newNode->index=i++; scanf("%f",&newNode->score); temp->next=newNode; temp->newNode; }}void (){ struct stu *head; head=(struct stu*)malloc(sizeof(struct stu)); head->next=NULL; CreateList(head);}void Insert(struct stu *head){ int index; float score; struct stu *NewNode=(struct stu *)malloc(sizeof(struct stu)); struct stu *p= head; printf("请输入要插入的学生编号;"); scanf("%d",&index); printf("请输入要插入的学生成绩:"); scanf("%f",&score); NewNode->index=index; NewNode->score=score; NewNode->next=NULL; printf("请输入要插入的位置;"); scanf("%d",&index); while(index>1&&p!=NULL) { p=p->next; index--; } NewNode->next=P->next; p->next=NewNode;}
参考答案