⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maxheapm.cpp

📁 数据结构算法vc++6.0程序集教材之part5
💻 CPP
字号:
//最大堆类的测试maxheapm.cpp
#include<iostream.h>
#include<iomanip.h>
#include<stdlib.h>
#include<conio.h>
typedef int ElemType;
#include "maxheap.cpp"
void PrintArray(int a[],int n)
{for(int i=0;i<n;i++)
  cout<<setw(3)<<a[i];
 cout<<endl;
}
void main()
{cout<<"maxheapm.cpp运行结果:\n";
 ElemType b[HeapSIZE];
 srand(350);
 for(int i=0;i<HeapSIZE;i++)
  b[i]=rand()%100;
 cout<<"输出数组b:\n";
 PrintArray(b,HeapSIZE);
 maxheap H(HeapSIZE),H1(HeapSIZE);
 for(i=0;i<HeapSIZE;i++)
  H.heapInsert(b[i]);
 cout<<"输出当前堆H的堆顶元素:\n";
 cout<<setw(3)<<H.GetTop()<<endl;
 cout<<"输出插入后数组b:\n";
 PrintArray(b,HeapSIZE);
 cout<<"输出逐个删除的H堆中元素:\n";
 while(!H.heapEmpty())
  cout<<setw(3)<<H.heapDelete();
 cout<<endl;
 for(i=0;i<HeapSIZE;i++)
  H1.heapInsert(rand()%100);
 cout<<"输出当前堆H1的堆顶元素:\n";
 cout<<setw(3)<<H1.GetTop()<<endl;
 cout<<"输出逐个删除的H1堆中元素:\n";
 while(!H1.heapEmpty())
  cout<<setw(3)<<H1.heapDelete();
 cout<<endl;
 H.Destroyheap();H1.Destroyheap();
 getch();}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -