主题:大家来做题吧!
天尝地酒
[专家分:870] 发布于 2007-08-18 08:16:00
矩阵
输入6行6列的矩阵,然后:
⑴输出矩阵
⑵将对角线之外的上三角形中的每个元素加1,下三角形中的每个元素减1,对角线元素的值不变,然后输出。
回复列表 (共2个回复)
沙发
Matodied [专家分:7560] 发布于 2007-08-18 13:59:00
太简单了,这不是送分吗???
总算抢来一个沙发了。
程序:
CLS
DIM a(6, 6)
FOR i = 1 TO 6: FOR j = 1 TO 6
PRINT "Input a("; i; ","; j; "):"; : INPUT a(i, j)
NEXT j, i
PRINT : PRINT "Array:"
GOSUB pri
PRINT : PRINT "Turned array:"
FOR i = 1 TO 6: FOR j = 1 TO 6
a(i, j) = a(i, j) + SGN(j - i)
NEXT j, i
GOSUB pri
END
pri:
FOR i = 1 TO 6: FOR j = 1 TO 6: PRINT a(i, j); : NEXT j: PRINT : NEXT i
RETURN
板凳
wzc1996 [专家分:1680] 发布于 2007-08-18 20:07:00
CLS
DIM A(6,6)
FOR I=1 TO 6:FOR J=1 TO 6: PRINT "INPUT A("; I; ","; J; "):"; : INPUT a(i,j)
NEXT:NEXT
PRINT"原来的三角形"
FOR I=1 TO 6:FOR J=1 TO 6
PRINT USING"####";A(I,J);
NEXT:PRINT:NEXT
PRINT:PRINT
PRINT "改变后的三角形"
FOR I=1 TO 6:FOR J=1 TO 6
IF I<J THEN A(I,J)=A(I,J)+1 ELSE IF I>J THEN A(I,J)=A(I,J)-1
NEXT:NEXT
FOR I=1 TO 6:FOR J=1 TO 6
PRINT USING"####";A(I,J);
NEXT:PRINT:NEXT
我来回复