65,210
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <list>
#include <algorithm>
bool isXx( char c )
{
return (c == 'x' || c == 'X');
}
int main( )
{
using namespace std;
list <char> L;
list <char>::iterator Iter;
list <char>::iterator result;
L.push_back( 'a' );
L.push_back( 'x' );
L.push_back( 'b' );
L.push_back( 'X' );
L.push_back( 'c' );
cout << "L = ( " ;
for ( Iter = L.begin( ) ; Iter != L.end( ) ; Iter++ )
cout << *Iter << " ";
cout << ")" << endl;
result = find_if( L.begin( ), L.end( ), isXx );
if ( result == L.end( ) )
cout << "There is no element like x or X."
<< endl;
else
result++;
cout << "There is an element like x or X in list L,"
<< "\n and it is followed by a "
<< *(result) << "." << endl;
system("pause");
}
#include<iostream>