3.创建“SALLINFO.DBF”表(商品编号(C,6),售价(N,8,1)),并与“PROINFO.DBF”建立关联,关联
字段为“商品编号”。(要求使用SQL语句)
4.将“PROINFO.DBF”表所有“商品单位”为“听”,商品类别为“0001”的商品“库存下限”调整为200。
(要求使用SQL语句)
5.按不同“商品类别”计算“PROINFO.DBF”表中“商品单价”的平均值。(要求使用SQL语句) 五、程序分析(本大题共2小题,每小题5分,共10分,读程序并分析结果,请填写在答题纸上) 1.分析下面的Visual Basic程序,循环体中的语句s = s + 1循环了_______次。
Option Base 1
Private Sub Command1_Click() Dim i As Integer Dim s As Integer Dim k As Integer i = 0: s = 0
a = Array(80, 20, 100, 40, 70, 60, 50, 10, 90, 30) For k = 1 To 10
For i = a(k) To 1 Step -1 If i >= 45 Then goto Lab1 s = s + 1 Next i Lab1: Next k Print s End Sub
2.分析下面的Visual FoxPro程序,要使输出结果为VhayagawVgavIx,则输入的字符串应
为 。 CLEAR
ACCEPT \请输入字符串:\N=LEN(CHARIN) DIME YCHAR(N) FOR I=1 TO N IF I % 2=0
YCHAR(I)=SUBSTR(CHARIN,I,1) ELSE
YCHAR(I)=UPPER(SUBSTR(CHARIN,I,1))
11
ENDIF ENDFOR FOR I=1 TO N/2 TEMP=YCHAR(I) YCHAR(I)=YCHAR(N-I+1) YCHAR(N-I+1)=TEMP ENDFOR DCHAR=\FOR I=1 TO N
IF ASC(YCHAR(I))>=ASC(\ DCHAR=DCHAR+LOWER(CHR(ASC(\ ELSE
IF ASC(YCHAR(I))>ASC(\ DCHAR=DCHAR+UPPER(CHR(ASC(\ ELSE
DCHAR=DCHAR+YCHAR(I) ENDIF ENDIF ENDFOR ?DCHAR
六、写出下列程序的运行结果(本大题共5小题,每小题5分,共25分,请将答案填写在答题纸上) 1.分析下面Visual Basic程序。窗体中有一命令按钮(名称为Command1)。
Option Base 1
Private Sub Command1_Click() Dim i As Integer Dim k As Integer Dim m As Integer
a = Array(6, 4, 8, 2, 1, 3, 9, 12, 43, 67, 8) For i = 1 To 10 For k = i + 1 To 11 If a(i) > a(k) Then
a(i) = a(i) + a(k): a(k) = a(i) - a(k): a(i) = a(i) - a(k) End If Next k
If a(i) >= 10 Then a(i) = Int(a(i) / 10)
12
Next i
If a(i) >= 10 Then a(i) = Int(a(i) / 10) m = 0
For i = 1 To 11 m = m + a(i) Next i Print m End Sub
窗体启动后,单击命令按钮,窗体显示的结果为________。
2.分析下面Visual Basic程序。如图所示,界面中有两个文本框和一个命令按钮,上面有字符的控件是
文本框1(名称Text1),中间的控件是文本框2(名称Text2),最下面的控件是命令按钮(名称Command1)。
Private Sub Command1_Click() Dim num As String Dim num1 As String Dim num2 As String Dim c As String Dim i As Integer Dim length As Integer Dim length1 As Integer Dim length2 As Integer length1 = 0: length2 = 0 num = Text1.Text length = Len(num) For i = 1 To length c = Mid(num, i, 1) If c <> \ num1 = num1 + c
13
length1 = length1 + 1 Else
If length1 > length2 Then length2 = length1: num2 = num1 length1 = 0: num1 = \ Else
length1 = 0: num1 = \ End If End If Next i
If length1 > length2 Then num2 = num1 End If
Text2.Text = num2 End Sub
窗体运行后,在文本框1中输入图中所示的字母和数字,单击命令按钮,则在文本框2显示的内容是__________________。 3.有如下Visual FoxPro程序:
CLEAR PUBLIC C,D A=12345678 B=10 C=20 D=30 N=0
DO SUB1 WITH A,B ?A,B,C,D PROCEDURE SUB1 PARAMETERS X,Y PRIVATE C Y=0 FLAG=.T. DO WHILE FLAG Y=X+Y*10 X=INT(X/10)
14
N=N+1 I=0 E=Y DO WHILE I<=N
E=E*10 I=I+1
ENDDO D=E+D IF X<100
FLAG=.F.
ENDIF ENDDO
C=STR(X)+STR(Y) RETURN ENDPROC
运行上面的程序,显示的结果为: 。
4.现有表“CJB.DBF”,结构为:BJ_NAME(C,30)、XM(C,8)、YW(N,4,1),表中数据如下图所示:
有如下Visual FoxPro程序: ACCEPT \请输入班级名:\USE CJB.DBF
INDEX ON YW TAG YWSX DIME TEMP(10) K=0 SAV=0 N=0
DO WHILE NOT EOF()
15