Quickly Sort

xiaoxiao2021-04-03  266

Yesterday I do Astar. Solved The First Problem.now Record Some Import AlogritHMS i Consider.

Quick Sort.here I don't need to say more.it's so fatiar.it always performances well.

// Quickly Sort

INT Partition (Bl Langs [], int low, int high);

Void Qsort (Bl Langs [], int low, int high);

INT Partition (Bl * LANGS, INT I, INT J)

{

INT low;

INT high = j;

Char PK [10];

Char Record [255];

STRCPY (PK, LANGS [I] .f);

STRCPY (RECORD, LANGS [I] .s);

// *****************************************

While (low

{

While (low = 0))

HIGH = high-1;

STRCPY (LANGS [LOW] .f, langs [high] .f);

STRCPY (LANGS [LOW] .s, LANGS [High] .s);

While (Low

Low = low 1;

STRCPY (LANGS [high] .f, langs [low] .f);

STRCPY (langs [high] .s, langs [low] .s);

}

STRCPY (LANGS [Low] .f, PK);

STRCPY (LANGS [Low] .s, Record);

Return Low;

}

Void Qsort (BL * LANGS, INT LOW, INTHIGH)

{

INT I;

IF (low

{

I = Partition (LANGS, LOW, HIGH);

QSort (LANGS, LOW, I-1);

Qsort (LANGS, I 1, HIGH);

}

}

Struct Baidulang

{

Char f [10];

Char s [255];

}

Typedef struct baidulang BL;

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

New Post(0)