C++循环嵌套问题
最近看一个教程 《C++捷径教程》 里面有一个循环嵌套的例子调试不出来,请帮看下为什么按2后不运行Play
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
using namespace std;
void play(int m)
{
int t, x;
for (t = 0; t < 100; t++) {
cout << "Guess the number: ";
cin >> x;
if (x == m) {
cout << " Right \n";
return;
}
else if (x < m) {
cout << "Too low \n";
}
else cout << "Twoo High \n";
}
cout << "You'v used up all your queses. Try again. \n";
}
int main()
{
int option;
int magic;
magic = rand();
do {
cout << "1. Get a nuew magic number\n";
cout << "2. Play\n";
cout << "3.Quit\n";
do{
cout << "Enter your choice:";
cin >> option;
} while (option < 1 || option>3);
switch (option)
{
case 1:
magic = rand();
break;
case 2:
break;
case 3:
cout << "Goodbye\n";
break;
}
play;
}while (option != 3);
return 0;
}