Use QSort () to quickly sort the contents of the string

xiaoxiao2021-03-06  29

#include "stdafx.h" / * qsort.c: this program reads the command-line * parameters and uses qsort to sort the. it * The displays the sorted arguments. * /

#include #include #include

INT COMPARE (const void * arg2);

Void main (int Argc, char ** argv) {char A [255] = "1723649/0"; int K = strlen (a); QSORT ((void *) a, (size_t) strlen (a), Sizeof CHAR), Compare); Printf ("% s", a);}

INT COMPARE (Const Void * Arg1, Const Void * Arg2) {RETURN - ((CHAR *) ARG1) [0] - (CHAR *) Arg2) [0]); // Descending, this value takes a negative Ascending order}

转载请注明原文地址:https://www.9cbs.com/read-82518.html

New Post(0)