我是靠谱客的博主 超帅草丛,这篇文章主要介绍c语言链表查找成绩不及格,C语言链表实现学生成绩信息的管理,现在分享给大家,希望可以做个参考。

C语言链表实现学生成绩信息的管理

更新时间:2017/2/9 1:33:00  浏览量:597  手机版

/*---------------------------------------------- // Student.cpp : 链表实现对学生成绩的管理

------------------------------------------------*/ #include

#include

#include

using namespace std;

struct Student

{ int id;

char *name;

float score;

Student *next;

};

Student* Create();

Student* Create(int i, char *ch, float sc); void Insert(Student *h, Student *p);

void Output(Student *h);

Student* Search(Student *h, const int id); void Delete(Student *h, Student *p);

int main(int argc, char* argv[])

{ Student *head, *p;

head=Create();

p=Create(1,"a",83);

Insert(head,p);

p=Create(2,"b",97);

Insert(head,p);

p=Create(3,"c",64);

Insert(head,p);

p=Create(4,"d",76);

Insert(head,p);

p=Create(5,"e",83);

Insert(head,p);

Output(head);

p=Search(head,2);

Delete(head,p);

Output(head);

return 0;

}

Student* Create()

{ Student *head;

head=(Student *)malloc(sizeof(Student)); head->next=NULL;

return head;

}

Student* Create(int i, char *ch, float sc)

{ Student *p;

p=(Student *)malloc(sizeof(Student)); p->id=i;

p->name=ch;

p->score=sc;

p->next=NULL;

return p;

}

void Insert(Student *h,Student *p)

{ /*

Student *cur;

cur=h;

while(cur->next!=NULL)

{ cur=cur->next;

}

cur->next=p;

*/

if(h->next==NULL)

{ h->next=p;

}

else

{

Student *cur,*q;

for(q=h->next;q!=NULL;q=q->next)

{ if(q->id>p->id)

break;

}

for(cur=h; cur->next!=q; cur=cur->next);

最后

以上就是超帅草丛最近收集整理的关于c语言链表查找成绩不及格,C语言链表实现学生成绩信息的管理的全部内容,更多相关c语言链表查找成绩不及格,C语言链表实现学生成绩信息内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部