VFP编程题求解

VFP编程题求解,第1张

程序1

clear

?"1992-2020年中间的闰年有:"

for year=1992 to 2020

if year%4==0 and year%100!=0 or year%400==0

?year

endif

endfor

程序2

clear

s=0

for i=100 to 999

if i%11=0

if i%10=8 or i/10%10=8 or i/100=8

?i

s=s+1

endif

endif

endfor

?"三位数中总亏信共有销誉轮",s,"个能被11整除同时又含有8的数字"

程序3

clear

a="Long long ago,there was a war between the birds and the beats. No one knows what they fought about.The bat did not know whose side he should take. He thought and thought, "

c="then decided he must try to be on the side of the winners.So he watched from far away. After a while, it seemed that the birds were going to win.He flew over to join them"

b=""

i=1

for j=1 to len(a)

if substr(a,j,1)!=" "

b=b+substr(a,j,1)

endif

endfor

for j=1 to len(c)

if substr(c,j,1)!=" "

b=b+substr(c,j,1)

endif

endfor

?b

程序4

input "虚圆请输入数字:" to n

P=2*N-1

FOR I=1 TO P

IF I<=N

?SPACE(N-I+1)

FOR J=1 TO 2*I-1

??"*"

ENDFOR

ELSE

?SPACE(I-N+1)

FOR K=1 TO 2*(2*N-I)-1

??"*"

ENDFOR

ENDIF

ENDFOR

1

note 计算表蚂运达式的值

set talk off

input "猛物态请输入x:"to x

input "请输入y:"to y

input "请输入z:"to z

?(x+y+z)/枝源3-X*Z^(1/2)

set talk on

2.

CLEAR

INPUT "请输入年份" TO Y

IF MOD(Y,4)=0 AND MOD(Y,100)<>0 OR MOD(Y,400)=0

MSG="是闰年"

ELSE

MSG="不是闰年"

ENDIF

?STR(Y,4)+"年"+MSG

3.

SET TALK OFF

CLEAR

INPUT '请输入X的值:' TO X

IF X%2=0

?’这是一个偶数!’

ELSE

?’它是一个奇数’

ENDIF

SET TALK ON

RETURN

4.

input "输入一个数 "to x

do case

case x<1

y=x

case x<10

y=2*x-1

otherwise

y=3*x-11

endcase

?"y=",y

5.INPUT "请输入成绩(0-100): " TO I

DO CASE

CASE I<=59

?"不及格"

CASE I<=74

?"及格"

CASE I<=89

?"良好"

CASE I<=100

?"优秀"

OTHERWISE

?"成绩无效"

ENDCASE

6.

SET TALK OFF

CLEAR

S=0

FOR I=1 TO 50

IF MOD(I,7)!=0

S=S+1

ENDIF

ENDFOR

?"1-50不能被7整除的数有:",S ,"个"

SET TALK ON

上述答案有错误。

==只能用于字符型敏正数据精确比较,不能用于数值型氏好数据。

应改为:if i%4=0 and i%100<歼拿铅>0 or i%400=0


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8204196.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-14
下一篇2023-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存