112年 關務特考 四等 資訊處理 程式設計概要 試卷

pdf
83.54 KB
4 頁
windows10
侵權投訴
加載中. ..
PDF
112年公務人員特種考試關務人員身心障礙人員考試及
112
關務人員考試
四等考試
資訊處理
程式設計概要
試時間:1小時 30 座號:
注意使用電計算器。
科目除專詞或理公,應使用本文字答。
14330
4
1
一、試回答下列有關程式設計領域的問題:(每小題 5分,共 20 分)
撰寫程式時皆要取變數名稱variable name與其資料型態data type
試問這兩項的用意為何?
程式敘述有時會以陣列array或串列list來表示試問其功用為何?
物件導向程式設計中的多型(polymorphism)的功用為何?
何謂多載函式(overloading function)?
二、下列是 C程式語言所撰寫的兩數對調它使用傳址呼叫來完成試修正下
列程式錯誤的地方程式在 main()函式中先輸入兩個整數並印出對調前
的兩數呼叫 swap()對調函式最後印出對調後的兩數出結果如下
24 分)
Enter two numbers:100 200
a = 100, b = 200
a = 200, b = 100
/* 兩數對調程式 */
#include <stdio.h>
void swap(int , int);
int main()
{int a, b;
printf("enter two numbers:");
scanf("%d %d", a, b);
printf("a = %d, b = %dn", a, b);
swap(a, b);
printf("a = %d, b = %dn", a, b);
return 0;
}
代號:
14330
頁次:
4
2
void swap(int x, int y)
{int temp;
temp = x;
x = y;
y = temp;
}
三、下 Python
。每,若
3 30
total = 0
for i in range(1, 100):
total += i
print(&apos;total =&apos;, total)
total = 0
i = 1
while i<=100:
total += i
i += 1
print(&apos;total =&apos;, total)
total = 0
i = 1
while i<=100:
i += 1
total += i
print(&apos;total =&apos;, total)
代號:
14330
頁次:
4
3
total = 0
for i in range(2, 100, 2):
total += i
print(&apos;total =&apos;, total)
total = 0
i = 1
while i<=100:
total += 1
i += 1
print(&apos;total =&apos;, total)
total = 0
i = 1
while i<=100:
total += i
i += 2
print(&apos;total =&apos;, total)
total = 0
for i in range(100, 1, -1):
total += i
print(&apos;total =&apos;, total)
total = 0
i = 100
while i>0:
total += i
i= 1
print(&apos;total =&apos;, total)
代號:
14330
頁次:
4
4
下列的程式,若依序輸入的數值是 123456
total = 0
i = 1
while i <= 5:
num = eval(input(&apos;Enter a number: &apos;))
if num % 5 == 0:
break
else:total += num
i += 1
print(&apos;total =&apos;, total)
下列的程式,若依序輸入的數值是 123456
total = 0
i = 1
while i <= 5:
num = eval(input(&apos;Enter a number: &apos;))
if num % 5 == 0:
continue
else:total += num
i += 1
print(&apos;total =&apos;, total)
四、利用 PythonCC++JavaC#五種程式語言的任一種程式語言,撰寫
一程式用以模擬大樂透的電腦選號6個介 149 之間不同的號碼)
輸出時要由小至大排列。(26 分)
收藏 ⬇️ 下載