VF实验报告答案
实验报告:程序设计答案
⌘ 求圆环面积,分别用子程序、过程、函数实现。 用子程序实现: 主程序:
Set talk off Clear S=0
Input “请输入大圆的半径:” to r1 Input “请输入小圆的半径:” to r2 Do area with r1,r2 ?“圆环的面积为:”,s Set talk on Return
用过程实现: 主程序:
Set talk off Clear S=0
Input “请输入大圆的半径:” to r1 Input “请输入小圆的半径:” to r2 Set procedure to sub1 Do area with r1,r2 ?“圆环的面积为:”,s Close procedure Set talk on Return
用函数实现: 主程序: Set talk off Clear
Input “请输入大圆的半径:” to r1 Input “请输入小圆的半径:” to r2 S=area( r1,r2)
?“圆环的面积为:”,s Set talk on Return
子程序:area.prg
Parameters k1,k2
S=Pi()*k1*k1-Pi()*k2*k2 Return
过程文件sub1.prg
Procedure area(k1,k2) S=Pi()*k1*k1-Pi()*k2*k2 Return Endproc
函数:area.prg
Parameters k1,k2
m=Pi()*k1*k1-Pi()*k2*k2 Return m
⌘ 从1-200,若该数能被3整除且末位数为5则显示该数。 Set talk off Clear
For i=1 to 200
If mod(i,3)=0 .and. mod(i,5)=0 .and. mod(i,10)0 ?i Endif Endfor Set talk on Return
⌘ 从键盘上接受一个字符串,统计该字符串中包含的数字字符(0~9)的总个数并显示出来。 set talk off clear s=0
accept
if asc(j)>=48 .and. asc(j)
?
⌘ 从键盘上接受一个字符串,以相反的顺序将其显示出来(例如,若输入为“aBxyxty1”,
则输出应为“1ytxyxBa”)。
set talk off clear s=
accept
?
return
⌘ 若基本工资大于等于600元,增加工资20%,若小于600元大于等于400元,则增加工
资15%,若小于400元则增加工资10%.请将rsgz.dbf表中的基本工资字段按此规则调整。
SET TALK OFF CLEAR CLOSE ALL
USE Rsgz Do While .not. eof() Do Case
Case 基本工资>=600
Replace基本工资 With基本工资*1.2 Case基本工资>=400 .and.. 基本工资
Replace基本工资 With基本工资*1.15 Case基本工资
Replace基本工资 With基本工资*1.10 Endcase Skip Enddo USE
SET TALK ON RETURN
⌘ 设有一张足够大的厚度为0.5毫米的纸,问至少折叠多少次可以达到(或超过)珠
穆朗玛峰(8844.43米)。
set talk off clear n=1
hight=0.5 do while .t. hight=hight*2 if hight>=8848130 ?
⌘ 输入三角形的三个边长A、B、C,若A、B、C能构成三角形,则计算出三角形
“构积 式中 W=(A+B+C)/2
SET TALK OFF CLEAR
INPUT
S=SQRT(W*(W-A)*(W-B)*(W-C))
?
IF A**2+B**2=C**2 .OR. B**2+C**2=A**2 .OR. C**2+A**2=B**2 ?
?
SET TALK ON Return ⌘ 某班学生计算机考试成绩已登记到COMPUTER.DBF自由表的成绩(N)型字段中,
另有评估(C型)字段。编程序将每个学生计算机的学习评估:“优秀”(90-100)“良好”(80-89)“中等”(70-79)“及格”(60-69)“不及格”(0-59),写到评估字段中。
SET TALK OFF CLEAR CLOSE ALL
USE COMPUTER
DO WHILE .NOT. EOF() DO CASE
CASE 成绩
REPLACE 评估 WITH “不及格” CASE 成绩
REPLACE 评估 WITH “及格” CASE 成绩
REPLACE 评估 WITH “中等” CASE 成绩
REPLACE 评估 WITH “良好” OTHERWISE
REPLACE 评估 WITH “优秀” ENDCASE SKIP ENDDO USE
SET TALK ON RETURN
⌘ 已知数据表N_list.dbf中只有一个数值型字段Data,且目前数据表中无记录,是编写程序,从键盘上接受20个数据存放到该数据表中,然后利用索引排序的方式找出这20个数据中的最大数和最小数并显示输出。
Set talk off Clear Close all
Dimension a(20) Use N_list For i=1 to 20 J=str(i,2)
Input “请输入第&j.个数:” to a(i) Append blank
Replace data with a(i)
Endfor
Index on data tag da Set order to da Go top
? “最小数是:” ,data Go bottom
? “最大数是:” ,data Use
Set talk on Return
实验报告:表单设计答案
1、 在一个表单Form1中,Xs.dbf在表单的数据环境中。有三个按钮
command1,command2,command3,command4分别在三个按钮的click事件中编写程序实现如下功能:点击command1,将command2的CAPTION改为“查询”,将command3的Caption改为“浏览”,将command4的Caption改为“退出”。点击command2对总价按售货员分类汇总,生成Xsb.dbf,并显示记录。点击command3浏览总价超过2000的人员信息。点击command4,退出表单运行并关闭数据表Xs.dbf。
按钮cmmand1的click事件的代码如下: Thisform.command2.caption=“查询” Thisform.command3.caption=“浏览” Thisform.command4.caption=“退出”
按钮cmmand2的click事件的代码如下: Select xs
Index on 售货员 tag shy Set order to shy
Total on 售货员 to xsb fields 总价 Use xsb Browse
按钮cmmand3的click事件的代码如下: Select xs
Browse for 总价>2000
按钮cmmand4的click事件的代码如下: Select xs Use
Thisform.release
2、 实现如下表单的功能。
(1)、在表单中的数据环境添加数据表Rsgl.dbf。
(2)、在表单上添加3个Label、3个Text和4个命令按钮。
表单Form1的Caption属性设置为“查询”。
Label1、Label2、Label3的Caption属性分别设置为“姓名”、“性别”、“文化程度”。 Text1、Text2、Text3的controlsource属性分别和RSGL表中的姓名、性别、文化程度
字段绑定。
Command1、Command2、Command3、Command4的Caption属性分别设置为“首记
录”、“上一条”、“下一条”、“末记录”。 (3)、在command1的clcik事件中添加代码如下: Go top
Thisform.refresh
在command2的clcik事件中添加代码如下: If not bof()
Skip-1
endif
Thisform.refresh
在command3的clcik事件中添加代码如下: If not eof() Skip Endif
Thisform.refresh
在command4的clcik事件中添加代码如下:
Go bottom
Thisform.refresh
3、 实现如下表单的功能。
(1)、在表单上添加2个Label、1个optiongroup、1个Text 和1个Shape,调整合适位置和
大小。
(2)、Label1、Label2的Caption属性分别设置为“选择颜色”、“选中的颜色”。
Optiongroup1的Autosize属性设置为.T.,buttoncount属性设置为5。
Optiongroup1中的option1、option2、option3、option4、option5的Caption属性分别设置为“红色”、“蓝色”、“绿色”、“黄色”、“白色”,Forecolor属性和Backcolor属性分别设置为所属颜色。
(3)、在Optiongroup1的click事件中添加代码如下: Dimension colorarray(5)
colorarray(1)=
thisform.shape1.backcolor=&colorarray(this.value) thisform.text1.value=this.buttons(this.value).caption thisform.refresh
4、 实现如下表单的功能。
(1)、在表单上添加3个Label、2个List、1个Text,调整合适位置和大小。 (2)、Label1、Label2、Label3的Caption属性分别设置为“选项列表”、“追加列表”、“您选
择的是”。
(3)、在Form1的Init事件中添加代码如下: thisform.list1.additem(
thisform.list1.additem(
thisform.list1.removeitem(this.listindex)
5、 实现如下表单的功能。
(1)、在表单的数据环境中添加两个数据表分别是RSGL.DBF和RSGZ.DBF。
(2)、在表单上添加1个Pagefreame,其Pagecount属性设置为2,调整合适位置和大小。 (3)、将Pagefreame1中的Page1、Page2的Caption属性分别设置为“浏览RSGL”、“浏览
RSGZ”。
(4)、分别在Page1、Page2中各添加一个控件Grid,调整合适位置和大小。 (5)、将Page1内的Grid1的Recordsourcetype属性设置为“别名”,Recordsource属性设置为
RSGL。
将Page2内的Grid1的Recordsourcetype属性设置为“别名”,Recordsource属性设置为
RSGZ。