甲8傳新增code上去

This commit is contained in:
2018-03-09 00:20:11 +08:00

View File

@ -4,6 +4,26 @@
using namespace System; using namespace System;
bool Guess(int number) bool Guess(int number)
{ {
static int target = -1;
if (target == -1)
{
Random r;
target = r.Next() % 100 + 1;
}
if (number > target)
{
std::cout << "Smaller" << std::endl;
return false;
}
else if (number < target)
{
std::cout << "Bigger" << std::endl;
return false;
}
return true;
} }
int main(array<System::String^>^ args) int main(array<System::String^>^ args)
{ {
@ -11,7 +31,6 @@ int main(array<System::String^>^ args)
do do
{ {
std::cout << "Choose a number between 1 - 100 :";
std::cin >> guess; std::cin >> guess;
} }
while (!Guess(guess)); while (!Guess(guess));