• 沒有找到結果。

程式設計

N/A
N/A
Protected

Academic year: 2021

Share "程式設計"

Copied!
6
0
0

加載中.... (立即查看全文)

全文

(1)

國立台中師範學院九十二學年度研究所碩士班考試

程式設計 科試題

測統所、數教系 用

壹、選擇題(每題 2.5 分,共 75 分)

Please answer the question (1) to question (4) after the following BASIC program is executed. 10 FOR K=2 TO 100 11 N=INT(SQR(K)) 12 FOR L=2 TO N 13 IF ( K MOD L=0) THEN GO TO 16 14 NEXT L 15 PRINT K 16 NEXT K 17 END

(1) How many values of variable K is printed? X23 Y31 Z28 [25 (2) Which is the largest number of printed K value? X100 Y97 Z96 [98 (3) Which is the smallest number of printed K value? X3 Y4 Z2 [7 (4) Which is the fifteenth number of printed K value? X47 Y61 Z54 [43

Please answer the question (5) to question (8) after the following BASIC program is executed. 10 N=23460 11 I=1 12 I=I+1 13 IF N MOD I <>0 THEN 12 14 PRINT I 15 N=N/I 16 IF N <> 1 THEN 13 17 END

(5)How many values of variable I is printed? X4 Y5 Z6 [7

(6)Which is the largest number of printed I value? X23 Y25 Z20 [27 (7)Which is the smallest number of printed I value? X5 Y3 Z4 [2 (8)Which is the fourth number of printed I value? X2 Y3 Z5 [4

(2)

(9) There is a integer array X represented in row-major order, if the address of X[3, 5] is 1000, and the address of X[5,7] is 1200. Which statement is wrong?

X The number of column is 49, Y The address of X[8, 10] is 1600, Z The address of X[3, 8] is 1016,

[ Each element in the array occupies 2 bytes.

(10) Which program segment is to insert a node in the linked list? (Suppose the inserted node named NEW, which is inserted after a node named Pointer) X NEW->Next = Pointer Pointer = NEW, Y NEW->Next = Pointer->Next Pointer->Next = NEW, Z Pointer->Next = NEW->Next NEW->Next = Pointer, [ none of the above.

(11)Which program segment is to delete a node in the linked list? (Suppose the deleted node named Pointer, which is deleted after a node named Back) X free(Pointer),

Y Back = Pointer->Next free(Pointer),

Z Back->Next = Pointer->Next free(Pointer),

[ none of the above.

(12) This is a recursive program segment. int fact(int N) { if N <=0 return 1; else return N * fact(N-1); }

Which statement is correct?

X The number of computing fact(N) is N Y fact(7) = 5040

Z fact(8) = 40302 [ none of the above

(3)

(13) What is the number of executing statement S in the following program segment? for(k = 1; k<=n; k++)

for(i = 0; i<k; i++) for(j = 0; j<k; j++)

if i≠j then S X n2

(n+1)/3 Yn(n+1)/2 Z n2(n+1)/2 [ none of above

(14) There is a sequence, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16. What is the number of key comparison to find 14 by fibonacci search?

X 5 Y 4 Z 3 [ 2

(15) There is a sequence, 15, 21, 25, 31, 49, 51, 69, 70, 74, 85, 87. What is the number of key comparison to find 85 by binary search?

X 5 Y 4 Z 3 [ 2

(16) What is the sum of the costs in the minimal spanning tree reduced from the following graph by Prim's algorithm?

X 132 Y 88 Z 97 [ 79 2 7 1 7 A B D F G 3 2 1 9 1 5 3 0 4 0 C E 1 8 8 3 3 7 請依據下列 C++程式,回答第(17)題至第(21)題: #include "stdafx.h" #include "Example01.h" #include "Example01Doc.h" #include "Example01View.h" IMPLEMENT_DYNCREATE(CExample01View, CView) BEGIN_MESSAGE_MAP(CExample01View, CView) ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() CExamlpe01View::CExample01View( ) { } CExample01View::~CExample01View( ) { }

(4)

void CExample01View::OnDraw(CDC* pDC) { CExampleDoc* pDoc = GetDocument();

pDC->TextOut(325, 200, "Hello World"); }

BOOL CExample01View::OnPreparePrinting(CPrintInfo* pInfo) { return DoPreparePrinting(pInfo); }

void CExample01View::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) { } void CExample01View::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) { } (17) 請問這段程式的主要目的是什麼? X宣告一個物件 Y建構一個列印程式 Z執行一個完整的視窗程式 [定義一個類別的成員函式 (18) 請問下列那一個函式是建構程式碼? X IMPLEMENT_DYNCREATE( ) Y CExample01View( ) Z ~CExample01View( ) [ OnBeginPrinting( ) (19) 請問這個程式會對幾種事件做反應? X 3 Y 2 Z 1 [ 0 (20) 請問下列何者是 cs 的類別? X CView Y CExample01View Z CREATESTRUCT [ CExample01Doc (21) 請問執行這個程式後,其所顯示的視窗會出現下列那一個情況? X顯示 Hello World Y顯示一個對話方塊 Z顯示一個列印訊息 [除非使用者按其按鈕,否則沒有任何顯示

(5)

請依據下列 C++程式,回答第(22)題至第(25)題: #include "stdafx.h"

#include <iostream> using namespace std;

int _tmain(int argc, _TCHAR* argv[]) { float x = 1.23E+30; float y = x + 1; cout<<"y - x ="<<y - x<<"\n"; return 0; } (22) 請問執行這段程式後,所顯示的結果是什麼? X y – x =1 Y y – x =0 Z y – x =1\n [ overflow (23) 請問執行這段程式後,y 的數值為何? X 1.23E+31 Y 2.23E+30 Z 1.23E+30 [ 2.23E+31 (24) 請問 #include <iostream> 的目的為何? X使用 cout Y使用 std Z使用 _TCHAR [使用 _tmain (25)請問下列何者是 cout 的類別? X C++ Y String Z char [ iostream

(6)

請依據下列敘述,回答第(26)題至第(29)題:

設某一程式的 input size 為 n ,running time 為T n ,且定義三種集合如下: ( )

1 2 0

1 2

( ( )) { ( ) : there exist postive constants , , and

such that 0 ( ) ( ) ( ), for all }

g n f n c c n c g n f n c g n n n Θ = ≤ ≤ ≤ ≥ 0 0 0

( ( )) { ( ) : there exist postive constants , and such that 0 ( ) ( ), for all }

O g n f n c n f n cg n n n = ≤ ≤ ≥ 0 0

( ( )) { ( ) : there exist postive constants , and such that 0 ( ) ( ), for all }

g n f n c n cg n f n n n Ω = ≤ ≤ ≥ (26) 設 ( ) 9 ( ) 3 n T n = T n + 下列何者為T n 最精確之範圍? ( ) nΘ(n2) o O n( 2) pΘ( logn 2n) qO n( 2log2n) (27) 設 ( ) (2 ) 1 3 n T = T n + 下列何者為T n 最精確之範圍? n ( )

nΘ( )n oΘ(log2n) pΘ( logn 2 ) qΘ(3log2n)

(28)設 ( ) 3 ( ) log2 4 n T n n = + T n 下列何者為T n 最精確之範圍? ( )

nO n( 2) oΘ(n2log2n) pΘ( logn 2n) qΩ( logn 2n)

(29)下列敘述何者為真? n Any comparison sort runs in Ω( logn 2n)

o Any comparison sort runs in O n( log2n)

p Any comparison sort can be optimized to run in O n( ) q Any comparison sort can be optimized to run in Θ( logn 2n)

(30)下列為 Merge Sort 之 pseudo code,其中 A[p,…,r] 為欲排序之陣列(array), Merge(X,Y)表將 X, Y 二陣列合併成一陣列,[ ] 為高斯符號。 Merge-Sort(A, p, r) if p<r then q = [(p+r)/2] X=Merge-Sort(A,p,q) Y=Merge-Sort(A,q+1,r) Merge(X,Y)

此 Merge Sort 之 worst-case running timeT n 最精確範圍為下列何者? ( ) nΘ(n2) oΩ(n2) pO n( 2log2n) qΘ( logn 2n)

貳、簡答題(每題 12.5 分,共 25 分)

(1)請用 c 或 c++ 設計一函數使其具有類似 basic mid$ 函數之功能。 例如:

str=”Something happened yesterday” mid$(str,11,6)=>happen

參考文獻

相關文件

微算機原理與應用 第6

 Request.Cookies[ &#34;Cookie 名稱&#34; ].Value –取得使用者所傳送的 Cookie 內容. 

National Taiwan University July 9, 2005 Page 5..

Beauty Cream 9001, GaTech DVFX 2003.

Life in Paints, GaTech DVFX 2003.. Tour

(b) Write a program (Turing machine, Lisp, C, or other programs) to simulate this expression, the input of the program is these six Boolean variables, the output of the program

3. Works better for some tasks to use grammatical tree structure Language recursion is still up to debate.. Recursive Neural Network Architecture. A network is to predict the

Special effects (make-up) Special effects (physical effects). Special effects (miniature) Special effects