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

📄 selsort1.cpp

📁 data structures, algorithms and Application书的源代码
💻 CPP
字号:
// selection sort

#include <iostream.h>
#include "swap.h"
#include "max.h" // max of n elements

template<class T>
void SelectionSort(T a[], int n)
{// Sort the n elements a[0:n-1].
   for (int size = n; size > 1; size--) {
      int j = Max(a, size);
      Swap(a[j], a[size - 1]);
      }
}

void main(void)
{
   int y[10] = {3, 2, 4, 1, 6, 9, 8, 7, 5, 0};
   SelectionSort(y,10);
   for (int i=0; i<10; i++)
      cout << y[i] << ' ';
   cout << endl;
}

⌨️ 快捷键说明

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