Learn fast sorting again (C language), learn sort C Language

Source: Internet
Author: User

Learn fast sorting again (C language), learn sort C Language

# Include <stdio. h> void QuickSort1 (int * s, int left, int right) {int I, j, t, weight; if (left> right) return; if (left <right) {iterator = s [left]; // reference I = left; j = right; while (I! = J) {while (I <j & s [j]> = equals) j --; // from the right to the left, find the first number smaller than the base number while (I <j & s [I] <= strong) I ++; // from left to right find the first number larger than the baseline number if (I <j) // exchange two numbers {t = s [I]; s [I] = s [j]; s [j] = t;} s [left] = s [I]; // Reference Data normalization s [I] = percentile; QuickSort1 (s, left, I-1); QuickSort1 (s, I + 1, right );}} void QuickSort2 (int * s, int left, int right) {int I, j, struct; if (left> right) return; if (left <right) {iterator = s [left]; // reference I = left; j = right; while (I! = J) {while (I <j & s [j]> = equals) j --; // find the first number that is smaller than the reference number from the right to the left. if (I <j) {s [I] = s [j]; I ++ ;} while (I <j & s [I] <= strong) I ++; // from left to right find the first number larger than the base number if (I <j) {s [j] = s [I]; j --;} s [I] = percentile; // Reference Data normalization QuickSort2 (s, left, I-1 ); quickSort2 (s, I + 1, right) ;}int main () {int a [] = }; // QuickSort1 (a,); QuickSort1 (a,); int I = 0; for (; I <10; I ++) printf ("% d ", a [I]); return 0 ;}

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.