51dev.com IT技术开发者社区

51dev.com 技术开发者社区

c++ 容器元素填充指定数量的元素(generate_n)

c++ 容器元素填充指定数量的元素(generate_n)

 #include<iostream>//cout#include<algorithm>//generate_nusingnamespacestd;intcurrent=0;intUniqueNumber(){return++current;}intmain(){i...

c++ 查找容器中不满足条件的元素,返回iterator(find_if_not)

c++ 查找容器中不满足条件的元素,返回iterator(find_if_not)

 #include<iostream>//std::cout#include<algorithm>//std::find_if_not#include<array>//std::arrayusingnamespacestd;intmain(){array...

c++ 容器元素遍历打印(for_each)

c++ 容器元素遍历打印(for_each)

 #include<iostream>//cout#include<algorithm>//for_each#include<vector>//vectorusingnamespacestd;voidmyfunction(inti){//function...

c++ 匹配A容器中最先出现的b容器中的元素,返回iterator,(find_first_of)

c++ 匹配A容器中最先出现的b容器中的元素,返回iterator,(find_first_of)

 #include<iostream>//std::cout#include<algorithm>//std::find_first_of#include<vector>//std::vector#include<cctype>//std::...

c++ 查找容器中符合条件的元素,并返回iterator(find_if)

c++ 查找容器中符合条件的元素,并返回iterator(find_if)

 #include<iostream>//std::cout#include<algorithm>//std::find_if#include<vector>//std::vectorusingnamespacestd;boolIsOdd(inti){r...

C++  在容器A中查找最后出现的容器B中的元素,并返回iterator(find_end)

C++ 在容器A中查找最后出现的容器B中的元素,并返回iterator(find_end)

 #include<iostream>//cout#include<algorithm>//find_end#include<vector>//vectorusingnamespacestd;boolmyfunction(inti,intj){retur...

c  assert 用法

c assert 用法

 #include<stdio.h>/*printf*/#include<assert.h>/*assert*/voidprint_number(int*myInt){assert(myInt!=NULL);printf("%d",*myInt);}intmain(...

222

222

 #include<iostream>//cout#include<algorithm>//find_end#include<vector>//vectorusingnamespacestd;voidpaint(int,int);voidjudge(in...

c 递归算法

c 递归算法

 #include<stdio.h>doublefactorial(unsignedinti){if(i<=1){return1;}returni*factorial(i-1);}intmain(){inti=15;printf("%d的阶乘为%f",i,factoria...

1111

1111

 if(A[0]>B[0]){    if(A[1]>B[1]){      for(inti=B[0];i<=A[0];i++){   &n...

c++ 查找数组或者容器元素是否存在(find)

c++ 查找数组或者容器元素是否存在(find)

  #include<iostream>//cout#include<algorithm>//find#include<vector>//vector#include<typeinfo>usingnamespacestd;intma...

c++ 容器填充指定长度(fill_n)

c++ 容器填充指定长度(fill_n)

 #include<iostream>//cout#include<algorithm>//fill_n#include<vector>//vectorusingnamespacestd;intmain(){vector<int>myvect...

c++ 返回指定元素连续相等的位置索引(equal_range)

c++ 返回指定元素连续相等的位置索引(equal_range)

 #include<iostream>//cout#include<algorithm>//equal_range,sort#include<vector>//vectorusingnamespacestd;boolmygreater(inti,intj...

c++ 容器元素填充(fill)

c++ 容器元素填充(fill)

 #include<iostream>//cout#include<algorithm>//fill#include<vector>//vectorusingnamespacestd;intmain(){vector<int>myvector...

c++ 判断两个容器是否相等(equal)

c++ 判断两个容器是否相等(equal)

 #include<iostream>//cout#include<algorithm>//equal#include<vector>//vectorusingnamespacestd;boolmypredicate(inti,intj){return(...