9vi.cpp

来自「《C/C++程序设计导论(第二版)》一书的程序源文件」· C++ 代码 · 共 26 行

CPP
26
字号
// InDictionary()  Accept an istream file var. for a disk file//   and a string var. for a word. Return true if the word is//   found in the dictionary disk file (else false).//   ASSUMPTION: file has already been opened//	IN: infile is file variable to an alphabetized lower-case dictionary//	IN:	user_word is a lower-case word.int InDictionary (ifstream& infile, string user_word){	int done = 0;					// loop completion flag	int found = 0;					// word-found flag	string dict_word;					// var for dictionary words	while (!done)	{	if (infile >> dict_word)				// get next dict. word...		{	if (user_word == dict_word)			// do words match?			{	done = 1;				found = 1;			}			else if (user_word < dict_word)				done = 1;			// searched too far.		}		else			done = 1;			// end of file.	}	return (found);				}

⌨️ 快捷键说明

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