C 练习实例74

C 语言教程 · 2019-02-22 12:29:27

题目:连接两个链表。

程序分析:无。

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include <stdlib.h> #include <stdio.h> struct list { int data; struct list *next; }; typedef struct list node; typedef node *link; link delete_node(link pointer,link tmp) { if (tmp==NULL) /*delete first node*/ return pointer->next; else { if(tmp->next->next==NULL)/*delete last node*/ tmp->next=NULL; else /*delete the other node*/ tmp->next=tmp->next->next; return pointer; } } void selection_sort(link pointer,int num) { link tmp,btmp; int i,min; for(i=0;i<num;i++) { tmp=pointer; min=tmp->data; btmp=NULL; while(tmp->next) { if(min>tmp->next->data) { min=tmp->next->data; btmp=tmp; } tmp=tmp->next; } printf("\40: %d\n",min); pointer=delete_node(pointer,btmp); } } link create_list(int array[],int num) { link tmp1,tmp2,pointer; int i; pointer=(link)malloc(sizeof(node)); pointer->data=array[0]; tmp1=pointer; for(i=1;i<num;i++) { tmp2=(link)malloc(sizeof(node)); tmp2->next=NULL; tmp2->data=array[i]; tmp1->next=tmp2; tmp1=tmp1->next; } return pointer; } link concatenate(link pointer1,link pointer2) { link tmp; tmp=pointer1; while(tmp->next) tmp=tmp->next; tmp->next=pointer2; return pointer1; } int main(void) { int arr1[]={3,12,8,9,11}; link ptr; ptr=create_list(arr1,5); selection_sort(ptr,5); }

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

CSS世界

CSS世界

张鑫旭 / 人民邮电出版社 / 2017-12 / CNY 69.00

本书从前端开发人员的需求出发,以“流”为线索,从结构、内容到美化装饰等方面,全面且深入地讲解前端开发人员必须了解和掌握的大量的CSS知识点。同时,作者结合多年的从业经验,通过大量的实战案例,详尽解析CSS的相关知识与常见问题。作者还为本书开发了专门的配套网站,进行实例展示、问题答疑。 作为一本CSS深度学习的书,书中介绍大量许多前端开发人员都不知道的CSS知识点。通过阅读本书,读者会对CSS......一起来看看 《CSS世界》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具