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

📄 sort.h

📁 这是本人精心搜集的关于常用图论算法的一套源码
💻 H
字号:
#include "SQList.h"
#include "Key.h"
typedef Key Record;

template <class Record>
class Sortable_list: public List<Record> 
{ public: 
    void insertion_sort( );
  private: 
  
};

template <class Record>
void Sortable_list<Record>::insertion_sort( )
{ int first_unsorted; //position of first_unsorted entry
  int position; //searches sorted part of list
  Record current; //holds the entry temporarily removed from list
  for(first_unsorted = 1; first_unsorted < count; first_unsorted++)
    if(entry[first_unsorted] < entry[first_unsorted-1])
      { position = first_unsorted;
        current = entry[first_unsorted]; // Pull unsorted entry out of the list.
        do{ // Shift all entries until the proper position is found.
            entry[position] = entry[position-1];
            position--; //position is empty.
          } while(position>0 && entry[position-1]>current);
        entry[position] = current;
      }
}

⌨️ 快捷键说明

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