2016計算機二級《VFP》上機操作題及答案
一、寫出下列程序的運行結果:
1.set talk off
y=1
if y<>0
x=3
else
x=5
endif
if x>4
if y<0
x=2
else
if x>0.and.y>0
x=12
else
x=30
endif
endif
else
x=5
endif
x
1、set talk off
a=100*rand( )
b=100*rand( )
c=100*rand( )
max=a
min=a
if max
max=b
endif
if min>b
min=b
endif
if max
max=c
endif
if min>c
min=c
endif
a,b
四、鍵盤輸入a,b,c的值,判斷它們能否構成三角形的三條邊,若能構成一個三角形,則計算三角形的面積。請用表單和建立命令文件兩種方法。
五、建立一個表單,如圖,開始自動顯示系統時間,當在文本框中輸入一個數值后,按“之前”或“之后”按鈕,使可顯示指定天數之前或之后的日期和星期。
參考答案
一、寫出下列程序的運行結果:
1.set talk off
y=1
if y<>0
x=3
else
x=5
endif
if x>4
if y<0
x=2
else
if x>0.and.y>0
x=12
else
x=30
endif
endif
else
x=5
endif
x
2、set talk off
a=100*rand( )
b=100*rand( )
c=100*rand( )
max=a
min=a
if max
max=b
endif
if min>b
min=b
endif
if max
max=c
endif
if min>c
min=c
endif
a,b
第1題:5
第二題:產生100以內的兩個隨機數
二、輸入3個不同的數,將它們從大到小排列。如圖,請寫出“排序”按鈕的單擊事件代碼。
三、鍵盤輸入一個數,判斷它能否同時被3、5、7整除的命令文件。
*編程思想:一個數被3、5、7除的余數若都為零,即能同時被三個數整除
input "請輸入一個數:" to A
if A%5=0 and A%3=0 and A%7=0
A,"能同時被3,5,7整除"
ELSE
A,"不能同時被3,5,7整除"
ENDIF
四、鍵盤輸入a,b,c的值,判斷它們能否構成三角形的三條邊,若能構成一個三角形,則計算三角形的面積。請用表單和建立命令文件兩種方法。
* 命令文件形式
input "請輸入第一邊的邊長:" to a
input "請輸入第二邊的邊長:" to b
input "請輸入第三邊的邊長:" to c
if (a+b)>c and (a-b)
p=(a+b+c)/2
S=sqrt(p*(p-a)*(p-b)*(p-c))
"三角形的面積為:",S
exit
else
"不能構成三角形,請重新輸入正確的邊長值"
cancel
endif
*command的click事件代碼:
a=val(alltrim(thisform.text1.value))
b=val(alltrim(thisform.text2.value))
c=val(alltrim(thisform.text3.value))
p=(a+b+c)/2
if a+b<=c or a-b=>c
messagebox("輸入的邊長值不能組成三角形",0+16+0,"輸入錯誤")
else
Thisform.label1.caption=sqrt(p*(p-a)*(p-b)*(p-c))
Endif
五、建立一個表單,如圖,開始自動顯示系統時間,當在文本框中輸入一個數值后,按“之前”或“之后”按鈕,使可顯示指定天數之前或之后的日期和星期。
顯示幾天前后的日期和星期
請寫出表單的Init事件,“之前”、“之后”、“今天”和“退出”按鈕的單擊事件代碼。
Init事件代碼:
ThisForm.label2.caption=alltrim(str(year(date())))+"年"+ alltrim(str(month(date())))+"月"+ alltrim(str(day(date())))+"日"
ThisForm.label3.caption= " 星期"+substr("日一二三四五六",2*dow(date())-1,2)
之前CLICK代碼:
A=val(alltrim(Thisform.text1.value))
ThisForm.label2.caption=alltrim(str(year(date()-A)))+"年"+ alltrim(str(month(date()-A)))+"月"+ alltrim(str(day(date()-A)))+"日"
ThisForm.label3.caption= " 星期"+substr("日一二三四五六",2*dow(date()-A)-1,2)
Thisform.refresh
之后CLICK代碼:
A=val(alltrim(Thisform.text1.value))
ThisForm.label2.caption=alltrim(str(year(date()+A)))+"年"+ alltrim(str(month(date()+A)))+"月"+ alltrim(str(day(date()+A)))+"日"
ThisForm.label3.caption= " 星期"+substr("日一二三四五六",2*dow(date()+A)-1,2)
Thisform.refresh
今天CLICK代碼:
ThisForm.label2.caption=alltrim(str(year(date())))+"年"+ alltrim(str(month(date())))+"月"+ alltrim(str(day(date())))+"日"
ThisForm.label3.caption= " 星期"+substr("日一二三四五六",2*dow(date())-1,2)
Thisform.refresh
退出CLICK代碼:
ThisForm.release
【計算機二級《VFP》上機操作題及答案】相關文章:
全國計算機二級《VFP》上機操作題及答案08-23
計算機二級《VFP》上機操作試題及答案08-13
如何備考計算機二級VFP上機考試10-14
計算機二級《VFP》試題及答案10-22