2015 Questions Practice

Source: Internet
Author: User



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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.