阿摩線上測驗 登入

申論題資訊

試卷:101年 - 101 鐵路特種考試_高員三級_資訊處理:程式語言#26236
科目:程式語言
年份:101年
排序:0

申論題內容

三、以下是以 C-like 的語言編寫的一段程式碼,請用以分別解釋如以靜態領域法(Static scoping)與動態領域法(Dynamic scoping)處理變數範圍的話,程式執行結果分別 為何?(應加以解釋)(10 分) int x; Sub1(void) { /* start of Sub1 function */ printf('x = %d', x); } /* end of Sub1 */ Sub2 (void) { /* start of Sub2 function */ int x; x:= 10; Sub1(); } /* end of Sub2 */ main() { /* begin of main function */ x = 15; Sub2(); } /* end of main */