11-02-01-2.cpp
来自「more efftive 代码」· C++ 代码 · 共 30 行
CPP
30 行
#include <iostream>#include <algorithm>#include <iterator>using namespace std;template <class Integer>struct congruent { congruent(Integer mod) : N(mod) {} bool operator()(Integer a, Integer b) const { return (a - b) % N == 0; } Integer N;};int main(){ int A[10] = {23, 46, 81, 2, 43, 19, 14, 98, 72, 51}; int digits[3] = {1, 2, 3}; int *seq = search(A, A + 10, digits, digits + 3, congruent<int>(10)); if (seq != A + 10) { cout << "Subsequence: "; copy(seq, seq + 3, ostream_iterator<int>(cout, " ")); cout << endl; } else cout << "Subsequence not found" << endl; // 块
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?