|
全国计算机考试二级FoxBASE程序修改题题型
第一题:给定程序MODI1.PRG 的功能是:识别用户密码,保护系统不被非授权用户使用。该程序给用户三次输入密码的机会(要求输入的密码不显示在屏幕上),超过三次,系统退出。用户密码保存在P1DB数据库中。修改调试如下程序,使之能正确运行。改错要求:程序中共有三处错误,请修改*****found****下面的错误,并调试运行。
注意:要求在原来位置修改,不得增加或删减程序行。
set talk off
set exact on
clear
k=0
do while k<3
@ 10,10 say "请输入密码: "
*******************found********************
set console off &&原句为set safety on
accept to mima
*******************found********************
set console on &&原句为set safety off
use p1db
locate all for trim(code)==mima
*******************found********************
if .not. eof() &&原句为if code=&mima
clear
@ 10,10 say "你好,欢迎光临!"
wait "请按任意键,进入系统开始执行程序"
exit
else
@ 10,10 say "您输入的密码不对"
n=80000
do while n>=1
n=n-1
enddo
endif
k=k+1
enddo
if k>=3
@ 15,10 say "对不起,您不能使用本系统"
n=80000
do while n>=1
n=n-1
enddo
endif
set talk on
return
第二题:给定程序MODI1.PRG 的功能是:用户在P2DB数据库中选择并修改数据库记录,然后根据用户的意愿存入或放弃修改。修改调试如下程序,使之能正确运行。
改错要求:程序中共有三处错误,请修改*****found****下面的错误,并调试运行。 注意:要求在原来位置修改,不得增加或删减程序行。(资料来源:东方教育网
Http://www.eastedu.com.cn)
set talk off
dimension unchange(3)
store "y" to ans,conti
use p2db
count to rno
r=1
do while conti="y"
clear
@ 2,2 say "修改第几条记录?" get r range 1,rno
read
go r
**********************found************************
scatter to unchange &&原句为store to unchange
@ 4,10 say "学号" get unchange(1) picture "999999"
@ 6,10 say "姓名" get unchange(2)
@ 8,10 say "所属z系" get unchange(3)
**********************found************************
read &&原句为store to unchange
@ 10, 2 say "准备存入你修改过的记录吗?(Y/N) " get ans
read
if upper(ans)="Y"
**********************found*************************
gather from unchange &&原句为append from to unchange
endif
@ 12,2 say "继续吗?" get conti
read
if upper(conti)<>"Y"
exit
endif
enddo
set talk on
return
第三题:给定程序MODI1.PRG的功能是:根据银行流水帐,同时修改银行和个人帐目。P3DB1为银行数据库,包括:支行号,名称,现有资金三个字段。P3DB2是个人数据库,包括:帐号,姓名,密码,余额四个字段。P3DB3是银行流水帐数据库,包括:帐号,支行号,日期,金额,存取,其中“存取”字段为逻辑型数据,存入其值为真T,取出其值为假F。另外,假设所有银行的初始资金为800000元,所有个人的初始资金为20000元,修改调试如下程序,使之能正确运行。
sele 1
use p3db1
replace all 现有资金with 800000
index on 支行号to id1
sele 2
use p3db2
replace all 余额with 20000
index on 帐号to id2
sele 3
use p3db3
set relation to 支行号into A
**************found****************
set relation to 帐号into B ADDITIVE &&原句为set relation
go top
do while .not.eof()
**************found****************
if 存取&&原句为if 存取=.t.
sele 1
replace 现有资金with 现有资金+ c->金额
sele 2
replace 余额with 余额+ c->金额
else
sele 1
replace 现有资金with 现有资金- c->金额
sele 2
replace 余额with 余额- c->金额
endif
sele 3
**************found****************
SKIP &&原句为loop
enddo
sele 1
list
wait
sele 2
list
wait
第四题:给定程序MODI1.PRG 具有书店的图书和订购管理查询功能,它可以由用户自由选择图书数据库或订购数据库,还能自由选择数据库中的任意字段进行查询。请修改并调试程序,使之正确运行。
set talk off
do while .t.
clear
@ 4,16 say "书店信息管理"
@ 6,16 prompt "1-图书管理" message "书店现有图书信息"
@ 8,16 prompt "2-订购管理" message "客户订单管理"
@ 10,16 prompt "0-退出" message "结束工作"
set message to 18
********************found*****************************
menu to m &&原句为accept to m
do case
case m=1
filename="p4db1"
case m=2
filename="p4db2"
otherwise
exit
endcase
sele 1
********************found*****************************
use &filename &&原句为use filename
copy to p4db3 structure extended
sele 2
use p4db3
do while .t.
clear
@ 1,4 say "请选择字段名:"
go top
i=3
do while .not.eof() &&显示所选数据库的字段名
j=1
do while j<=5.and..not.eof()
@ i,(j-1)*10+4 prompt field_name
skip
j=j+1
enddo
i=i+2
enddo
***************************found**********************
menu to n &&原句为select menu
go n
store field_name to fname
sele 1
disp all fields &fname
wait
sele 2
exit
enddo
close all
enddo
set talk on
return
第五题:给定程序MODI1.PRG 的功能是:往P5DB2学生数据库中输入学生信息,为了保持参照完整性,系名信息必须是P5DB1学校数据库系名字段所拥有的值。为此,MODI1.PRG采用了选择菜单的方法录入系名字段值,选择菜单的菜单项内容,就是P5DB1学校数据库的系名字段值。(资料来源:东方教育网
Http://www.eastedu.com.cn)
set talk off
dimension array(3) &&为存储学生记录
store 200000 to array(1) &&为学号
store " " to array(2) &&为姓名
store " " to array(3) &&为所属系系名
use p5db2
zap
select 1
use p5db1 &&为包括系号,系名的学校信息数据库
index on 系名to p5db1
count to n
x=1
dimension d(n)
go top
do while .not.eof() &&将所有系的系名存入数组中
store 系名to d(x)
x=x+1
skip
enddo
select 2
c="y"
use p5db2 &&学生信息数据库
do while c="y"
clear
@ 2,4 say "请输入学生信息"
@ 4,4 say "系名"
@ 6,4 say "学号"
@ 8,4 say "姓名"
@ 2,20 clear to 20,79
@ 4,20 say "选择系名"
x=1
do while x@ row()+1,20 prompt d(x)
x=x+1
enddo
*******************found********************
menu to a &&原句为accept to a
dept=d(a)
@ 2,20 clear to 20,79
@ 4,4 say "系名"+ dept
store dept to array(3)
*******************found********************
@ 6,4 say "学号" get array(1) range 1,200099 &&原句为...
for 学号>1.and.学号< 200099
@ 8,4 say "姓名" get array(2)
read
append blank
*******************found********************
gather from array &&原句为append from array
@ 12,4 say "继续吗?(Y/N)" get c
read
if lower(c)="n"
exit
endif
enddo
disp all
set talk on
return
第七题:给定程序MODI1.PRG 的功能是:选择最小号空闲区,若最小号空闲区号大于1, 说明系统当前已有工作区被占用,在这种情况下,测试最小号空闲工作区的前一个工作区打开的数据库文件名,该数据库的字段数和记录数。注:假设字段数和记录数均小于10。修改调试如下程序,使之能正确运行。
改错要求:程序中共有三处错误,请修改*****found****下面的错误,并调试运行。 注意:要求在原来位置修改,不得增加或删减程序行。(资料来源:Http://www.eastedu.com.cn)
SET TALK OFF
SELECT 1
USE DB1
SELECT 3
USE DB2
SELECT 5
USE DB3
*********FOUND************
SELECT 0 &&原句为select X
A=SELECT()
IF A>1
SELECT A-1
FILENAME=ALIAS()
**********FOUND************
store fcount() to fnum &&原句为SUM FIELD TO fnum
**********FOUND************
count to recnum &&原句为SUM TO RECNUM
CLEAR
@ 6,6 SAY "在"+STR((A-1),1)+"区中已经打开了:" + FILENAME
@ 7,6 SAY "该数据库中的字段数是:" + STR(FNUM,1)
@ 8,6 SAY "该数据库中的记录数是:" + STR(RECNUM,1)
ENDIF
SET TALK ON
RETURN
第八题:MODI1.PRG的功能是:在指定范围内产生一个由指定个数的整数构成的等差数列。修改调试如下程序,使之能正确运行。 改错要求:程序中共有三处错误,请修改*****found****下面的错误,并调试运行。
注意:要求在原来位置修改,不得增加或删减程序行。(资料来源:Http://www.eastedu.com.cn)
set talk off
do while .t.
store 1 to s,m,n
clear
@ 2,2 say "请输入等差数列的首项值: " get s
@ 3,2 say "请输入等差数列的最末项值: " get m
@ 4,2 say "请输入等差数列的项数:" get n range1,20
*****************found*****************
read &&原句为wait
d=int((m-s)/n) &&计算公差数
t=n
dimension a(n)
store 0 to a(n)
do while n>0
a(n)=s+(n-1)*d && 计算各项值
n=n-1
enddo
n=1
? "等差数列如下:"
do while n<=t
? a(n)
*****************found*****************
n=n+1 &&原句为 n=n-1
enddo
accept "还继续做吗?(y/n) " to c
if lower(c)="n"
exit
endif
*****************found*****************
clear memo &&原句为close memo
enddo
set talk on
return
第九题:MODI1.PRG 的功能是:为了保证数据库数据的正确性,用户首先在数组中输入并修改欲存入数据库的数据,经用户确认输入正确后,再存入数据库中。修改调试如下程序,使之能正确运行。
改错要求:程序中共有三处错误,请修改*****found****下面的错误,并调试运行。 注意:要求在原来位置修改,不得增加或删减程序行。(资料来源:Http://www.eastedu.com.cn)
set talk off
set date american
set century on
clear gets
dimension a(6)
a(1)=space(10)
a(2)=" "
********************found*********************
store 0 to a(3),a(4) &&原句为a(3),a(4)=0
a(5)=ctod("01/01/1999")
a(6)=.t.
do while .t.
clear
@ 4,4 say "食品物名称 " get a(1) picture "@n"
@ 5,4 say "出产国: " get a(2) picture "@a"
@ 6,4 say "数量: " get a(3) range 1,1000
@ 7,4 say "单价: " get a(4) picture "$$$$$9.99" range
0,99999
@ 8,4 say "生产日期:" get a(5) range ctod("01/01/1999"),date()
@ 9,4 say "检验合格吗?(y/n)" get a(6) pict "Y"
*****************************found********************************
read &&原句为wait
accept "输入的数据正确吗? y/n " to ans
***************************found********************************
if uppe(ans)="Y" &&原句为if ans="Y"
exit
endif
wait "请修改"
enddo
wait "将把数据存入数据库中"
set talk on
return
第十题:为了使输入数据库的数据满足规定的条件,MODI1.PRG 在用户输入数据时作出限制,以保证用户输入的数据在规定的范围之内。修改调试如下程序,使之能正确运行。
改错要求:程序中共有三处错误,请修改*****found****下面的错误,并调试运行。 注意:要求在原来位置修改,不得增加或删减程序行。(资料来源:Http://www.eastedu.com.cn)
set talk off
set date american
set century on
clear gets
*****************found******************
dime a(6) &&原句为array a(6)
a(1)=space(8)
a(2)=space(2)
a(3)=20
a(4)=123.45
a(5)=date()
a(6)=.t.
do while .t.
clear
@ 4,4 say "姓名: " get a(1) picture "aaaaaaaa"
@ 5,4 say "性别: " get a(2) picture "aa" vali a(2)$"男女"
@ 6,4 say "年龄: " get a(3) range 1,120
@ 7,4 say "工资: " get a(4) picture "$$$$9.99"
*****************found******************
@ 8,4 say "参加工作日期:" get a(5) range ctod("01/01/1970"),date()
&&原句为for a(5)>= ctod("01/01/1970").and.a(5)<=date()
@ 9,4 say "婚否? " get a(6) picture "Y"
*****************found******************
read &&原句为input
accept "要修改吗? y/n " to ans
if upper(ans)="N"
exit
endif
wait "按任意键返回修改"
enddo
wait "是否存入数据库?(Y/N)"
set talk on
return
(资料来源:Http://www.eastedu.com.cn)
|