2016計(jì)算機(jī)二級(jí)《VFP》上機(jī)操作題及答案
一、寫出下列程序的運(yùn)行結(jié)果:
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的值,判斷它們能否構(gòu)成三角形的三條邊,若能構(gòu)成一個(gè)三角形,則計(jì)算三角形的面積。請(qǐng)用表單和建立命令文件兩種方法。
五、建立一個(gè)表單,如圖,開(kāi)始自動(dòng)顯示系統(tǒng)時(shí)間,當(dāng)在文本框中輸入一個(gè)數(shù)值后,按“之前”或“之后”按鈕,使可顯示指定天數(shù)之前或之后的日期和星期。
參考答案
一、寫出下列程序的運(yùn)行結(jié)果:
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
第二題:產(chǎn)生100以內(nèi)的兩個(gè)隨機(jī)數(shù)
二、輸入3個(gè)不同的數(shù),將它們從大到小排列。如圖,請(qǐng)寫出“排序”按鈕的單擊事件代碼。
三、鍵盤輸入一個(gè)數(shù),判斷它能否同時(shí)被3、5、7整除的命令文件。
*編程思想:一個(gè)數(shù)被3、5、7除的余數(shù)若都為零,即能同時(shí)被三個(gè)數(shù)整除
input "請(qǐng)輸入一個(gè)數(shù):" to A
if A%5=0 and A%3=0 and A%7=0
A,"能同時(shí)被3,5,7整除"
ELSE
A,"不能同時(shí)被3,5,7整除"
ENDIF
四、鍵盤輸入a,b,c的值,判斷它們能否構(gòu)成三角形的三條邊,若能構(gòu)成一個(gè)三角形,則計(jì)算三角形的面積。請(qǐng)用表單和建立命令文件兩種方法。
* 命令文件形式
input "請(qǐng)輸入第一邊的邊長(zhǎng):" to a
input "請(qǐng)輸入第二邊的邊長(zhǎng):" to b
input "請(qǐng)輸入第三邊的邊長(zhǎng):" 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
"不能構(gòu)成三角形,請(qǐng)重新輸入正確的邊長(zhǎng)值"
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("輸入的邊長(zhǎng)值不能組成三角形",0+16+0,"輸入錯(cuò)誤")
else
Thisform.label1.caption=sqrt(p*(p-a)*(p-b)*(p-c))
Endif
五、建立一個(gè)表單,如圖,開(kāi)始自動(dòng)顯示系統(tǒng)時(shí)間,當(dāng)在文本框中輸入一個(gè)數(shù)值后,按“之前”或“之后”按鈕,使可顯示指定天數(shù)之前或之后的日期和星期。
顯示幾天前后的日期和星期
請(qǐng)寫出表單的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
【計(jì)算機(jī)二級(jí)《VFP》上機(jī)操作題及答案】相關(guān)文章:
全國(guó)計(jì)算機(jī)二級(jí)《VFP》上機(jī)操作題及答案08-23
2016年9月計(jì)算機(jī)二級(jí)《VFP》上機(jī)操作題及答案07-06
計(jì)算機(jī)二級(jí)考試VFP操作題及答案10-02
2016計(jì)算機(jī)二級(jí)VFP考試上機(jī)操作題及解析08-10
2016年計(jì)算機(jī)二級(jí)《VFP》上機(jī)操作題09-24
計(jì)算機(jī)二級(jí)《VFP》上機(jī)考題與答案201605-30
計(jì)算機(jī)二級(jí)《VFP》上機(jī)操作試題及答案08-13