?? ch12.1.01.c
字號:
template < class ForwardIterator, class Type >
ForwardIterator
find( ForwardIterator first, ForwardIterator last, Type value )
{
for ( ; first != last; ++first )
if ( value == *first )
return first;
return last;
}
#include <iostream.h>
// #include <iostream>
/**
**
stanl@john:d.12 303 : a.out
enter search value: 210
The value 210 is present
stanl@john:d.12 304 : a.out
enter search value: 42
The value 42 is not present
**
**/
int main()
{
int search_value;
int ia[ 6 ] = { 27, 210, 12, 47, 109, 83 };
cout << "enter search value: ";
cin >> search_value;
int *presult = find( ia, ia+6, search_value );
cout << "The value " << search_value
<< (presult == &ia[6]
? " is not present" : " is present" )
<< endl;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -