select.cpp

来自「这是数据结构、算法与应用-C++语言描述的代码」· C++ 代码 · 共 24 行

CPP
24
字号
// test select

#include <iostream>
#include <algorithm> // has copy
#include "select.h"

using namespace std;

int main()
{
   int a[10] = {10,7,8,9,4, 2, 3, 6, 5,1};
   int n = 10;

   // output the elements
   cout << "a[0:9] = ";
   copy(a, a+10, ostream_iterator<int>(cout, " "));
   cout << endl;

   // select and output
   for (int i = 1; i <= n; i++)
      cout << "The " << i << "'th element is " << select(a, n, i) << endl;
   return 0;
}

⌨️ 快捷键说明

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