📄 pr07005.cpp
字号:
////////////////////////////////////////
// File Name: pr07005.cpp
////////////////////////////////////////
#include <iostream>
#include <cstdlib>
#include <ctime>
////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
std::srand(time(0));
char ans;
// Loop until the user is done.
do
{
// Choose a secret number.
int fav = std::rand() % 32;
// Loop until the user guesses the secret number.
int num;
do
{
std::cout << "Guess my secret number (0 - 32) ";
std::cin >> num;
// Report the status of the guess.
std::cout << (num < fav ? "Too low" :
num > fav ? "Too high" :
"Right") << std::endl;
}
while (num != fav);
std::cout << "Go again? (y/n) ";
std::cin >> ans;
}
while (ans == 'y');
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -