【建站服务】靖江公众号代运营公司-域名申请
作者: 风兰 . 阅读量: 3 . 发表时间:2022-09-21 04:04:44
上往建站提供服务器空间服务商,百度快照排名,网站托管,百度推广运营,致力于设计外包服务与源代码定制开发,360推广,搜狗推广,增加网站的能见度及访问量提升网络营销的效果,主营:网站公司,百度推广公司电话,官网搭建服务,网站服务企业排名,服务器空间,英文域名等业务,专业团队服务,效果好。
靖江公众号代运营公司

<stdlib.h> #define NULL 0#define LEN sizeof(struct student) struct student{ long num; float score; struct student *next;}; struct student *create(){ struct student *p1, *p2, *head; int num; float score; int n = 0; head = NULL; p1 = p2 = (struct student *)malloc(LEN); printf("please input num and score.n"); scanf("%d,%f", &p1->num, &p1->score); while(p1->num != 0) { n ++; if(n == 1) head = p1; else p2->next = p1; p2 = p1; p1 = (struct student *)malloc(sizeof(struct student)); printf("please input num and score.n"); scanf("%d,%f", &p1->num, &p1->score); } p2->next = NULL; return head;} void printlist(struct student *head){ struct student *p; p = head; if(head != NULL) {
head;
if(head != NULL)
{
do
{
printf("num=%d score=%f ", p->num, p->score);
p = p->next;
}while(p != NULL);
}
}
void main()
{
struct student *head;
head = create();
printlist(head);
system("pause");
}
以下是对链表的各种操作
打印链表:
void printlist(struct student *head)
{
struct student *p;
p = head;
if(head != NULL)
{
do
{
printf("num=%d score=%5.2f ", p->num, p->score);
p = p->next;
} while (p != NULL);
}
/* while(p -> next != NULL)
{
printf("num=%d score=%f ", p->num, p->score);
p = p->next;
}*/
}删除节点:
struct student *delNode(struct student *head, int num)
{
printf("delNode. ");
struct student *p1, *p2;
if(head == NULL)
{
printf("The List is NULL. ");
}
else
{
p1 = head;
while(p1->next != NULL && p1->num != num)
{
p2 = p1;
p1 = p1->next;
}
if(p1->num == num)
{
if(p1 == head)
head = p1->next;
else
p2->next = p1->next;
}
else
printf("Can not find list num. ");
}
return head;
}
更新节点:
struct student *update(struct student *head, int index, int num, float score)
{
printf("update. ");
struct student *p;
if(head == NULL)
{
printf("The List is NULL. ");
}
else
{
p = head;
while(p->next != NULL && p->num != index)
{
p = p->next;
}
if(p->num == index)
{
p->num = num;
p->score = score;
}
else
printf("Can not find list index. ");
}
return head;
}
增加节点:
struct student *add(struct student *head, int index, int num, float score)
{
printf("add. ");
struct student *p1, *p2, *p3;
if(head == NULL)
{
printf("The List is NULL. ");
}
else
{
p1 = p2 = head;
while(p1->next != NULL && p1->num != index)
{
p1 = p1->next;
p2 = p1;
}
if(p1->num == index)
{
p3 = (struct student *)malloc(LEN);
p3->num = num;
p3->score = score;
if(p2->next == NULL)
{
p2->next = p3;
p3->next = NULL;
}
else
{
p3->next = p2->next;
p2->next = p3;
}
}
else
printf("Can not find list index. ");
}
return head;
}
原文链接:http://www.cnblogs.com/qkhhxkj/archive/2011/06/28/2091818.html
参考书籍:谭浩强老师《C程序设计》一书中关于结构体类型的章节。
上往建站提供搭建网站,域名注册,官网备案服务,网店详情页设计,企业网店,专业网络店铺管理运营全托管公司咨询电话,服务器空间,微信公众号托管,网页美工排版,致力于域名申请,竞价托管,软文推广,全网营销,提供标准级专业技术保障,了却后顾之忧,主营:虚拟主机,网站推广,百度竞价托管,网站建设,上网建站推广服务,网络公司有哪些等业务,专业团队服务,效果好。
服务热线:400-111-6878 手机微信同号:18118153152(各城市商务人员可上门服务)
关键词:网站建设,企业网站,网站制作,网页设计,高端网站建设,企业网站制作,网页制作,制作网站,网站设计,高端网页设计,高端网站设计,做网站,自适应网站


