Home > Back-end >  C STL IsEven problem
C STL IsEven problem

Time:09-27

# include & lt; Iostream>
#include
#include

The template & lt; Typename elementType>
Bool IsEven (const elementType& Number)
{
Return (number % 2==0);
}

Int main ()
{
using namespace std;

vector VecIntergers;

For (int nNum=9; NNum & lt; 10; + + nNum)
VecIntergers. Push_back (nNum);

vector : : const_iterator iElementLocator;
For (iElementLocator=vecIntergers. The begin ();
IElementLocator!=vecIntergers. End ();
+ + iElementLocator)
Cout & lt; <* iElementLocator & lt; <" ";
Cout & lt;
Size_t nNumZeros=count (vecIntergers. The begin (), vecIntergers. The end (), 0).
Cout & lt; <" Vector in the vector "& lt;
Size_t nNumEvenElements=count_if (vecIntergers. The begin (), vecIntergers. The end (), IsEvenCout & lt; <"Are there in the vector" & lt; return 0;
}
This is all the code displays - nine to nine the number of the even number and the output of the predicate IsEven but run always wrong he has done

CodePudding user response:

Have a great god help me conveniently solve the no

CodePudding user response:

Appreciate for the great god

CodePudding user response:

Best to upgrade the compiler, VC6 using templates problems,

VS2015 directly compiled through,,

CodePudding user response:

reference akirya reply: 3/f
best to upgrade the compiler, VC6 using templates problems,

VS2015 directly compiled through,,


Rose once again when you have time now belongs to the review stage one of these days, ready to interview...
  • Related