Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template<typename T>
- bool execute( T* pBegin, T* pEnd, T* out )
- {
- T* pCur = pBegin;
- bool bFind = false;
- while( pCur != pEnd )
- {
- if( (*pCur & 1) )
- {
- if( !bFind ) *out = *pCur;
- else if( *out > *pCur ) *out = *pCur;
- bFind = true;
- }
- pCur++;
- }
- return bFind;
- }
- using namespace std;
- int main()
- {
- int A[] = { 10,4,32,2,10 };
- int min = 0;
- bool b = execute<int>( &A[0], &A[5], &min );
- if( b ) cout << "Min value is " << min << endl;
- else cout << "No such elements\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment