1.2015
(1):
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stddef.h>int cmp (const void *a, const void *b) {return * (int*) A-* (int*) b;} int main () {char strin[4096] = {' numresult[4096 '};char strtemp[4096] = {'};int '};int] = {0 = = 0; Result array index static int count = 0; The continuous number count while (get (strin) = NULL) {Sizein = strlen (Strin);//Gets the size of the input string, including the last Terminator if (Sizein! = 0) {//Gets the shaping array for (int i = 0; i < Sizein;) {//Get integer if (strin[i] >= ' 0 ' && strin[i] <= ' 9 ') {Strtemp[count] = strin[i];count++;} else//encounters non-numeric {if (count! = 0)//If there is a number, then takes out {//converts the resulting string into shaping numresult[resultcount++] = atoi (strtemp); memset (strtemp, 0, 4096); count = 0;}} i++;} if (count! = 0)//Gets the last integer {numresult[resultcount++] = atoi (strtemp); count = 0;} Qsort (Numresult, Resultcount, sizeof (int), CMP), for (int i = 0; i < resultCount-1; i++) {printf ("%d", Numresult[i]);} printf ("%d", numresult[resultcount-1]); Print the last element printf ("\ n"); resultcount = 0;count = 0;memset (strin, 0, 4096); memset (strtemp, 0, 4096); memset (Numresult, 0, 4096);}}
Attached: How to use quick sort
C Standard library Quick sort: http://blog.csdn.net/masibuaa/article/details/5633498
Quick ordering of C + +: http://blog.csdn.net/zzzmmmkkk/article/details/4266888
2015 Questions Practice