正在加载图片...
Design a generic algorithm vector<int> filter(const vector<int>&vec, int threshold) vector<int> nvec for (int iX=0; iX< vec size(; 1X++) if(vec[iX]<threshold) nvec.push back(vecIXD) return nvec ■ Request5 How to modify the above code to make it be capable of user specified comparisons. eg. <,>,<=Design a generic algorithm ◼ Request 5: ◼ How to modify the above code to make it be capable of user specified comparisons. eg. <, >, <=,… vector<int> filter(const vector<int> &vec, int threshold) { vector<int> nvec; for (int iX = 0; iX < vec.size(); iX++) if (vec[iX] < threshold) nvec.push_back(vec[iX]); return nvec; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有