⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alg47.c

📁 “在遇到无法解决的问题时
💻 C
字号:
#include <algorithm>
#include <vector>
#include <iostream.h>

/* generates:
Expecting to find two instances of 'o': o o 
Expecting to find the substring `mou':  m o u 
*/
	
int main() 
{
        ostream_iterator< char >  ofile( cout, " " );

	const char blank = ' ';
	const char oh    = 'o';

	char str[ 26 ]  = "oh my a mouse ate a moose";
	char *found_str = search_n( str, str+25, 2, oh );
		
	cout << "Expecting to find two instances of 'o': ";
        copy( found_str, found_str+2, ofile ); cout << '\n';

	vector< char, allocator > vec( str, str+25 );
		
	// find the first sequence in which three characters
	// do not equal a blank space: mou of mouse

	vector< char, allocator >::iterator iter;
        iter = search_n( vec.begin(), vec.end(), 3, 
			 blank, not_equal_to< char >() );
		
	cout << "Expecting to find the substring `mou':  ";
        copy( iter, iter+3, ofile ); cout << '\n';
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -