12-06-06-2.cpp

来自「more efftive 代码」· C++ 代码 · 共 22 行

CPP
22
字号
#include <iostream>#include <iterator>#include <algorithm>#include <vector>using namespace std;struct eq_div {  eq_div(int divisor) : n(divisor) {}  bool operator()(int x, int y) const { return x / n == y / n; }  int n;};int main() {  int A[] = {1, 5, 8, 15, 23, 27, 41, 42, 43, 44, 67, 83, 89};  const int N = sizeof(A) / sizeof(int);    vector<int> V;  unique_copy(A, A + N, back_inserter(V), eq_div(10));    copy(V.begin(), V.end(), ostream_iterator<int>(cout, "\n"));  // 块

⌨️ 快捷键说明

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