编写完美的软件 对开发者来说可能是一个难以达到的目标,但是应用一些
常规的防御性技术,对于提高代码的质量将会大有帮助
尽管软件产品的复杂性保证了测试人员有做不完的工作,然而,程序设计
人员仍然渴望创建零缺陷的软件
当用户回答猜测结果太大或太小时,出现 新计算出来的子范围不包括秘密
数字
因为一个谎言会导致另一个谎言,最终会使猜数范围缩减到不包含任何数字
//: C02:HiLo.cpp {RunByHand}
// From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison.
// (c) 1995-2004 MindView, Inc. All Rights Reserved.
// See source code use permissions stated in the file 'License.txt',
// distributed with the code package available at www.MindView.net.
// Plays the game of Hi-Lo to illustrate a loop invariant.
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Think of a number between 1 and 100" << endl
<< "I will make a guess; "
<< "tell me if I'm (H)igh or (L)ow" << en