How to use C-band qsort to quickly sort

Source: Internet
Author: User

1/can write to stdout fordebugging purposes, e.g.2 //printf ("This is a debug message\n");3#include <stdlib.h>4 5 intcmpConst void*P1,Const void*p2)6 {7     return*(int*) p1>* (int*) P2?1:-1;8 }9 intSolution (intA[],intN) {Ten     //Write your code in C99 One     //int len = sizeof (A)/sizeof (a[0]); A     //printf ("%d len \ n", Len); -Qsort (A,n,sizeof(int), CMP); -     inti; the      for(i=0; i<n-2; i++) -     { -         //printf ("%d \ n", A[i]); -         if(a[i+2]-a[i+1]<A[i]) +         { -             return 1; +         } A     } at     return 0; -}

Qsort

A: Array;

N: array length;

sizeof (int), the size of each element;

CMP: A function that compares two parameter sizes.

How to use C-band qsort to quickly sort

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.