⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex3_19.m

📁 《MATLAB程序设计教程》电子教案
💻 M
字号:
%Play the game of guess the number
x=fix(100*rand);   %a random number calculated by the computer
n=7;
test=1;
for k=1:7
    numb=int2str(n);
    disp(['You have a right to ',numb,' guesses'])
    disp(['A guess is a number between 0 and 100'])
    guess=input('Enter your guess:');
    if guess<x
        disp('Low')
    elseif guess>x
        disp('High')
    else
        disp('You won')
        test=0;
        break;
    end
    n=n-1;
end
if test==1
    disp('You lost')
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -