<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>C on Chunixz情报中心</title>
    <link>https://chunixz.github.io/tags/c/</link>
    <description>Recent content in C on Chunixz情报中心</description>
    <image>
      <title>Chunixz情报中心</title>
      <url>https://chunixz.github.io/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://chunixz.github.io/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- gohugo.io</generator><atom:link href="https://chunixz.github.io/tags/c/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Algorithms 十大排序算法总结</title>
      <link>https://chunixz.github.io/posts/2019-03-14-1/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://chunixz.github.io/posts/2019-03-14-1/</guid>
      <description>1. 排序算法分类 在计算机科学所使用的排序算法通常被分类为:
计算的时间复杂度（最差、平均、和最好性能），依据列表（list）的大小(n)。一般而言，好的性能是 O(nlogn)(大O符号)，坏的性能是 O(n^2)。对于一个排序理想的性能是 O(n)，但平均而言不可能达到。基于比较的排序算法对大多数输入而言至少需要 O(nlogn)。 内存使用量（以及其他计算机资源的使用）。 稳定性：稳定排序算法会让原本有相等键值的纪录维持相对次序。也就是如果一个排序算法是稳定的，当有两个相等键值的纪录 R和 S，且在原本的列表中 R出现在 S之前，在排序过的列表中 R也将会是在 S之前。 依据排序的方法：插入、交换、选择、合并等等。 1.1 稳定性 稳定排序算法会依照相等的关键（换言之就是值）维持纪录的相对次序。也就是一个排序算法是稳定的，就是当有两个有相等关键的纪录R和S，且在原本的串行中R出现在S之前，在排序过的串行中R也将会是在S之前。
1.2 计算复杂度 依据串行（list）的大小（n），一般而言，好的表现是O(nlogn)，且坏的行为是O(n2)。对于一个排序理想的表现是O(n)。仅使用一个抽象关键比较运算的排序算法总平均上总是至少需要O(nlogn)。 所有基于比较的排序的时间复杂度至少是 O(nlogn)。 1.3 常用排序算法 排序方法 时间复杂度（平均） 时间复杂度（最坏） 时间复杂度（最好） 空间复杂度 稳定性 冒泡排序 O(n^2) O(n^2) O(n) O(1) 稳定 插入排序 O(n^2) O(n^2) O(n) O(1) 稳定 选择排序 O(n^2) O(n^2) O(n^2) O(1) 不稳定 快速排序 O(nlogn) O(n^2) O(nlogn) O(nlogn) 不稳定 希尔排序 O(nlogn) O(n^2) O(n) O(1) 不稳定 堆排序 O(nlogn) O(nlogn) O(nlogn) O(1) 不稳定 归并排序 O(nlogn) O(nlogn) O(nlogn) O(n) 稳定 桶排序 O(n+k) O(n^2) O(n) O(n+k) 稳定 基数排序 O(n*k) O(n*k) O(n*k) O(n+k) 稳定 计数排序 O(n+k) O(n+k) O(n+k) O(n+k) 稳定 2.</description>
    </item>
    
    <item>
      <title>APUE 7-进程环境</title>
      <link>https://chunixz.github.io/posts/2019-03-31-1/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://chunixz.github.io/posts/2019-03-31-1/</guid>
      <description>7.1 引言 当进程执行时，其main函数是如何被调用的； 命令行参数是如何传递给新进程的； 典型的存储空间布局的样式； 如何分配另外的存储空间； 进程如何使用环境变量； 进程的不同终止方式； longjmp和setjmp函数以及它们与栈的交互作用； 进程资源限制； 7.2 main函数 C程序总是从main函数开始执行，main函数的原型是：
int main(int argc, char *argv[])； argc是命令行参数的数目； argv是指向参数的各个指针所构成的数组； 当内核执行C程序时，在调用main前先调用一个特殊的启动例程。可执行程序文件将此启动例程指定为程序的起始地址，由链接器设置，而链接编辑器则由C编译器调用。启动例程从内核获得命令行参数和环境变量值，然后为按上述方式调用main函数做好安排。
7.3 进程终止 有8种方式使进程终止，其中5种为正常终止，它们是： 从 main返回； 调用 exit； 调用 _Exit 或 _exit； 最后一个线程从其启动例程返回； 从最后一个线程调用 pthread_exit； 异常终止有3种，它们是： 调用 abort； 接到一个信号； 最后一个线程对取消请求做出响应； 退出函数
3个函数用于正常终止一个函数：_exit 和 _Exit立刻进入内核，exit 则先执行一些清理处理，然后返回内核。
#include &amp;lt;stdlib&amp;gt; void exit(int status); void _Exit(int status); #include &amp;lt;unistd.h&amp;gt; void _exit(int status); exit 函数总是执行一个标准 I/O库的清理关闭操作：对于所有打开流调用 fclose函数。输出缓冲中的所有数据都被冲洗。
3个推出函数都带一个整型参数，称为终止状态或退出状态，下面进程终止状态是未定义的：
调用这些函数时不带终止状态； main执行了一个无返回值 return语句； main没有声明返回类型为整型。 main函数返回一个整型值与用该值调用 exit是等价的。在main中 exit(0); 等价于 return(0);</description>
    </item>
    
    <item>
      <title>C library function - qsort()</title>
      <link>https://chunixz.github.io/posts/2019-03-26-1/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://chunixz.github.io/posts/2019-03-26-1/</guid>
      <description>Description The C library function **void qsort(void base, size_t nitems, size_t size, int (compar)(const void , const void)) sorts an array.
Declaration
Following is the declaration for qsort() function.
void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)) Parameters
base : This is the pointer to the first element of the array to be sorted. nitems: This is the number of elements in the array pointed by base.</description>
    </item>
    
    <item>
      <title>Interview_Notes</title>
      <link>https://chunixz.github.io/posts/2019-03-22-3/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://chunixz.github.io/posts/2019-03-22-3/</guid>
      <description>Interview_Notes C Linux 一、基础概念 1. 关键字static的作用是什么？ 二、。 三、。 </description>
    </item>
    
  </channel>
</rss>
