VF题,求高人们解答,谢谢

2025-01-24 06:14:04
推荐回答(2个)
回答1:

1、
clear
s=0
for i=1 to 100
s=s+i
endfor
?"S=1+2+3+4+5+。。。。。。+100=",s

2、
clear
input "请输入用电量:" to d
if d<=50
f=0.5*d
else
f=0.5*50+(d-50)*1
endif
?"电费是:",f

3、
clear
input "请输入学生成绩:" to cj
do case
case cj>=90
?"优秀"
case cj>=60 and cj<90
?"通过"
case cj<60
?"不及格"
endcase

回答2:

PROCEDURE Prg_01
CLOSE ALL
CLEAR ALL
CLEAR
nSum_S = 0
FOR nLoop_01 = 1 TO 100
nSum_S = nSum_S + nLoop_01
NEXT
?"S = 1+2+3+4+5......+100= ", nSum_S
*** 屏显:S = 1+2+3+4+5......+100= 5050
RETURN

PROCEDURE Prg_02
CLOSE ALL
CLEAR ALL
CLEAR
DO WHILE .T.
INPUT "请输入用电度数:" TO nGetNo
IF NOT TYPE([nGetNo]) = "N"
?"数据无效!"
ELSE
EXIT
ENDIF
ENDDO

IF nGetNo > 50
nTotal = (50 * 0.5) + ((nGetNo - 50) * 1)
ELSE
nTotal = nGetNo * 0.5
ENDIF
?"本月电费:", nTotal
RETURN

PROCEDURE Prg_03
CLOSE ALL
CLEAR ALL
CLEAR
DO WHILE .T.
INPUT "请输入学生的成綪:" TO nGetNo
IF NOT TYPE([nGetNo]) = "N" OR nGetNo < 0 OR nGetNo > 100
?"数据无效!"
ELSE
EXIT
ENDIF
ENDDO

DO CASE
CASE nGetNo > 90
?"优秀!"
CASE nGetNo < 60
?"不及格!"
OTHERWISE
?"通过!"
ENDCASE
RETURN