字母金字塔算法

算法 | 2015-04-21 13:45:17 | 3963次阅读 | 0评



CLEAR
FOR I=1 TO 26
    STORE "" TO A,B
    ?I,SPACE(26-I)
    FOR J=1 TO I
        A=A+CHR(J+64)
        IF J=1
            B=""
        ELSE
            B=CHR(J+63)+B
        ENDIF
    ENDFOR
    ?? A+B
ENDFOR

QQ截图20150421134358.png (上传于2015-04-21 13:45:17)
QQ截图20150421134358.png


数字金字塔代码



clear
for i=1 to 9
    store "" to a,b
    ?space(9-i) 
    for j=1 to i
        a=a+str(j,1)
        if j=1
            b=""
        else
            b=str(j-1,1)+b
        endif
    endfor
    ??a+b
endfor
效果图
        1
       121
      12321
     1234321
    123454321
   12345654321
  1234567654321
 123456787654321
12345678987654321


clear 
for i=1 to 9
    ?space(10-i)
    for j=1 to i
        ??str(j,1)+" "
    endfor
    for j=i-1 to 1 step -1
        ??str(j,1)+" "
    endfor
endfor


博友评论,共0条
浏览180287次
最新评论