求4道QBASIC题答案!1.编写程序统计10个数中奇数的和,偶数的乘积.2.编写程序,输出的图案如下:* * * *

2个回答

  • 1.

    DIM A(10)

    FOR I = 1 TO 10

    INPUT "SHU";A(I)

    NEXT I

    FOR I = 1 TO 10

    IF A(I) MOD 2 0 THEN HE=HE+A(I)

    NEXT I

    JI=1 ----注意,这里要负值1,因为0*任何数还是0

    FOR I = 1 TO 10

    IF A(I) = 0 THEN GOTO 10------0*任何数还是0

    IF A(I) MOD 2 = 0 THEN JI=JI*A(I)

    NEXT I

    PRINT HE,JI

    END

    2.

    CLS

    FOR I = 1 TO 5

    FOR J = 1 TO (5-I)+1

    PRINT "*";

    NEXT J

    NEXT I

    END

    3.

    CLS

    DIM A(3)

    FOR I = 1 TO 3

    INOUT A(I)

    NEXT I

    FOR I = 1 TO 2

    FOR J = I+1 TO 3

    IF A(I)>A(J) THEN SWAP A(I),A(J)

    NEXT J

    NEXT I

    FOR I = 1 TO 3

    PRINT A(I);

    NEXT I

    END

    4.

    CLS

    DO

    K=K+1

    S=S+K

    LOOP UNTIL S>=1000

    PRINT K

    END

    结果:K=45

    应该都是对的,除非我打错了,不知道符不符合你的要求,希望是对的!