高普考題庫
106 年 106年公務人員高等考試三級考試暨普通考試

程式設計概要

本卷皆為申論題,點「看答案與解析」查看擬答。

申論 1用C 語言撰寫一個函式void bit_pattern(unsigned num),它能將一個32-bit整數數值0 與1 的bit pattern 列印出來。例如數值是444 所列印出來的bit pattern 應該是00000000 00000000 00000001 10111100?(15 分)
申論 2用C 語言撰寫一個函式,能反轉一單向鍊結串列(singly linked list):struct node* reverse(struct node *h)。單向鍊結串列範例如圖一。(25 分)函式內請勿複製結點,其中節點的資料結構為struct node {int d;struct node *next;}h h反轉圖一、單向鍊結串列範例
申論 3用C 語言撰寫反覆結構(for-loop)及遞迴(recursive)2 個版本的函式,分別計算出費式數列(Fibonacci Sequence):int F(int n),其數學定義如下:F = 0, F = 1, and F = F + F for n >1。(25 分)01nn–1n–2例如: 呼叫 F(6) 計算出 8 and F(7) 計算出13。
申論 4在物件導向語言(JAVA or C++),宣告變數為public, private, protected,其差異性為何?(10 分)106年公務人員普通考試試題 代號:44150類科:資訊處理科目:程式設計概要
申論 5AJAX 即「Asynchronous JavaScript and XML」(非同步的JavaScript 與XML 技術)為一重要且普遍用來產生高互動網頁的技術,可讓使用者在執行AJAX 網頁時就像在執行桌上電腦程式(desktop application)一樣順暢(如圖二)。㈠請說明AJAX 三個主要技術為何並說明其目的。(9 分)㈡並請以以下網頁為例,當使用者輸入字元後的網頁反應,說明傳統非AJAX 與AJAX網頁不同之處。(10 分)㈢請說明網頁程式碼中‘xmlhttp.readyState==4’,‘xmlhttp.status==200’及‘"gethint.php?q="+str’代表的意義為何?(6 分)<html lang="en-US"><head><script>function showHint(str){if (str.length==0) {document.getElementById("txtHint").innerHTML=""; return;} else {var xmlhttp=new XMLHttpRequest();xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById("txtHint").innerHTML=xmlhttp.responseText; }};xmlhttp.open("GET","gethint.php?q="+str, true);xmlhttp.send();}}</script></head><body><div class="w3-example"><h3>Example</h3><form action="javascript:void(0);" class="w3-code-result"><p><b>Start typing a name in the input field below:</b></p><p> Name: <input type="text" id="txt1" onkeyup="showHint(this.value)" size="20">&nbsp;&nbsp;Suggestions: <span id="txtHint"></span> </p></form></div></body></html>圖二、2 個AJAX 範例程式執行結果