堆排序中第一个元素没排序?#includeusing namespace std;#define MaxSize 100typedef int KeyType;typedef struct {KeyType key;}RecType;void sift(RecType R[],int low,int high){int i=low,j=2*i;RecType tmp=R[i];while(j
来源:学生作业帮助网 编辑:作业帮 时间:2024/12/02 07:02:19
xROKA=b!]WDu)]w63 JA#?fJ_fgS_L{D1ʴGu˼5nd{dЇ3!E kHIEBMd4} D
Z
,βQ0
u` ŵ8j9@CIw>\iJEmp1:1DϡyQ(Q#h)ҋʇ:ߡ9Wϱ64b%?q_
9WSPEs
R;%=F|Yf0鬓j]".=hjIB.I_.̋IY\X2X89gLVag_rVB`nҼaB8dPbF ð
堆排序中第一个元素没排序?#includeusing namespace std;#define MaxSize 100typedef int KeyType;typedef struct {KeyType key;}RecType;void sift(RecType R[],int low,int high){int i=low,j=2*i;RecType tmp=R[i];while(j
堆排序中第一个元素没排序?
#include
using namespace std;
#define MaxSize 100
typedef int KeyType;
typedef struct
{
KeyType key;
}RecType;
void sift(RecType R[],int low,int high)
{
int i=low,j=2*i;
RecType tmp=R[i];
while(j
堆排序中第一个元素没排序?#includeusing namespace std;#define MaxSize 100typedef int KeyType;typedef struct {KeyType key;}RecType;void sift(RecType R[],int low,int high){int i=low,j=2*i;RecType tmp=R[i];while(j
主要原因是你的排序算法是从下标1开始,主函数中下标从0开始,改成一样的就可以了,下面是改过的主函数:
void main()
{
RecType R[MaxSize];
KeyType a[MaxSize];
cout