find

来自「C++ primer 4 书中源码」· 代码 · 共 29 行

TXT
29
字号
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 + =
减小字号Ctrl + -
显示快捷键?