main.cpp
来自「数据结构与程序设计教材源码 数据结构与程序设计教材源码」· C++ 代码 · 共 67 行
CPP
67 行
#include "../../C/UTILITY.H"
#include "../../C/UTILITY.CPP"
#include "../../B/RANDOM.H"
#include "../../B/RANDOM.CPP"
#include "../../6/CONTLIST/LIST.H"
#include "../../6/CONTLIST/LIST.CPP"
#include "KEY.H"
#include "KEY.CPP"
#include "RECORD.H"
#include "RECORD.CPP"
void write_entry(Record &c)
{
cout << ((Key) c).the_key() << " ";
}
#include "SORTABLE.H"
#include "INSERT.CPP"
#include "SELCTCON.CPP"
#include "SHELL.CPP"
#include "QUICKCON.CPP"
#include "HEAP.CPP"
main()
{
List<Record> s; List<Record> t = s; // help out the poor compiler!
int list_size = max_list;
Random dice;
int i;
Sortable_list<Record> the_list;
for (i = 0; i < list_size; i++) {
Record target = dice.random_integer(0,1999);
if (the_list.insert(i, target) != success) {
cout << " Overflow in filling list." << endl;
}
}
for (i = 0; i < 5; i++) {
Sortable_list<Record> copy_list = the_list;
cout << "\nUnsorted list \n";
copy_list.traverse(write_entry);
cout << "\n";
switch (i) {
case 0: copy_list.insertion_sort();
cout << "Insertion Sort ";
break;
case 1: copy_list.selection_sort();
cout << "Selection Sort ";
break;
case 2: copy_list.shell_sort();
cout << " Shell Sort ";
break;
case 3: copy_list.quick_sort();
cout << " Quick Sort ";
break;
case 4: copy_list.heap_sort();
cout << " Heap Sort ";
break;
}
cout << " Sorted list \n";
copy_list.traverse(write_entry);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?