1: Run the Code:
//3.24.cpp: Defines the entry point of the console application. //#include"stdafx.h"#include<iostream>using namespacestd;intMainintARGC, _tchar*argv[]) { Do{ intNum,kind,row; cout<<"enter a two-digit book number"<<Endl; CIN>>num; Kind= num/Ten; Row= num%Ten; if(kind<1|| Kind>4|| Row>4|| row<1) {cout<<"you entered the wrong"<<Endl; Continue;//looking for a cyclic judging condition, here is the while} cout<<"This book is located in"; Switch(kind) { Case 1: cout<<"Literature Bookshelf"; Break; Case 2: cout<<"Social Science Bookshelf"; Break; Case 3: cout<<"history book Rack"; Break; Case 4: cout<<"Biography Bookshelf"; Break; } cout<<"Section"<<row<<"Layer"<<Endl; Break;//find a location, jump out while} while(true);//infinite loops are available in this way return 0;}
View Code
Operation Result:
Introduction to C + + Classic-Example 3.24-Finding the location of a book