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

📄 alg10.c

📁 C++ PRIME书中的原代码,看本书时可以学习的例子.
💻 C
字号:
#include <algorithm>
#include <list>
#include <string>
	
int main() 
{
	int array[ 17 ] = { 7,3,3,7,6,5,8,7,2,1,3,8,7,3,8,4,3 };
	
	int elem = array[ 9 ];
	int *found_it;
		
	found_it = find( &array[0], &array[17], elem );


	// generates: find the first occurrence of 1 found!

	cout << "find the first occurrence of "
	     << elem << "\t"
	     << ( found_it ? "found!\n" : "not found!\n" );

        string beethoven[] = { 
 	"Sonata31", "Sonata32", "Quartet14", "Quartet15", 
	"Archduke", "Symphony7" };

	string s_elem( beethoven[ 1 ] );

        list< string, allocator > slist( beethoven, beethoven+6 );
	list< string, allocator >::iterator iter;

	iter = find( slist.begin(), slist.end(), s_elem );

	// generates: find the first occurrence of Sonata32  found!

	cout << "find the first occurrence of "
	     << s_elem << "\t"
	     << ( found_it ? "found!\n" : "not found!\n" );

	return 0;
}

⌨️ 快捷键说明

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