const int *my_find(const int *first, const int *last, int value)
{
while( first != last ) { // 処理範囲の間ループ
if( *first++ == value ) // value を発見したら
return first - 1; // そのアドレスを返す
}
return last; // 発見できなかった場合は last を返す
}
解説:
const int *my_find(const int *first, const int *last, int value)
{
while( first != last ) { // 処理範囲の間ループ
if( *first == value ) // value を発見したら
return first; // そのアドレスを返す
++first;
}
return last; // 発見できなかった場合は last を返す
}
前: | 次: