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

📄 find

📁 C++ primer 4 书中源码
💻
字号:
variable

//begin{find_word}
#include <string>
int main()
{
	// initialize a string to hold a word to search for 
	string search_word;
	cin >> search_word;
	
	// initialize a bool variable to false 
	bool found = false;
	
	string next_word;
	while ( cin >> next_word ) {
		if ( next_word == search_word )
		found = true;
	}
	
	//{ shorthand notation for: if ( found == true ) }
	if ( found )
		std::cout << "ok, we found the word" << std::endl;
	else 
		std::cout << "nope, the word was not present." << std::endl;

	return 0;
}
//end{find_word}

⌨️ 快捷键说明

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