我想寫這將產生以下輸出While循環和if/else語句在PL/SQL
exec WinOrLose(4)
Welcome to the Win or Lose Game. Your number is 4.
You win.
You lose.
You win.
You lose.
==> You lose!
程序到目前爲止,我有這樣的:
CREATE or REPLACE Procedure WinOrLose (
p_choice number) AS
v_answer number;
DECLARE
v_answer := p_choice
BEGIN
dbms_output.put_line ('Welcome to the Win or Lose Game. Your number is ' ||
v_answer);
FOR v_answer in 1..10
IF MOD(v_answer, 2) = 0 THEN -- v_answer is even
dbms_output.put_line (You lose)
END;
/
我不確定從那裏去哪裏。我的思維過程(僞碼)是這樣的:
SET v_answer := 1
While Loop (outside)
MOD(v_answer,2) = 0 then dbms.output (YOU LOSE)
ELSE
dbms.output (YOU WIN)
end if;
v_answer := p_choice
什麼是規則?查看代碼和僞代碼沒有任何意義。 –