當(dāng)前位置:
首頁(yè) >
C语言库函数(Q类字母)
發(fā)布時(shí)間:2025/6/15
37
豆豆
生活随笔
收集整理的這篇文章主要介紹了
C语言库函数(Q类字母)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
函數(shù)名: qsort
功 ?能: 使用快速排序例程進(jìn)行排序
用 ?法: void qsort(void *base, int nelem, int width, int (*fcmp)());
程序例: ?
#include <stdio.h>
#include <stdlib.h>
#include <string.h> ?
int sort_function( const void *a, const void *b); ?
char list[5][4] = { "cat", "car", "cab", "cap", "can" };
int main(void)
{
? int ?x; ?
? qsort((void *)list, 5, sizeof(list[0]), sort_function);
? for (x = 0; x < 5; x++)
? ? ?printf("%s\n", list[x]);
? return 0;
} ?
int sort_function( const void *a, const void *b)
{
? return( strcmp(a,b) );
}
轉(zhuǎn)載于:https://blog.51cto.com/liaosy/1213395
總結(jié)
以上是生活随笔為你收集整理的C语言库函数(Q类字母)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [WorldWind学习]17.视域调度
- 下一篇: HP小型机superdome配置MC双机