嵌套循环问题
帮看一下下面代码,按了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;
}