← 回題庫

卷別

資料結構及演算法

選擇

國立政治大學 2025 · 考試 · 第 6 題

考科演算法

(4%) Given the following algorithm, which is likely to be the result if the input variable N is -1?

Boolean Magic (int N)
{   if (N==1)
      Return True
    else if (N==0)
      Return False
    else { N = N-2;
      Return Magic(N);
    };
}
  • (A)
    -3
  • (B)
    True
  • (C)
    False
  • (D)
    Stack Overflow
  • (E)
    Syntax Error

標準解析

AI 已複查