主题:二维数组
016565
[专家分:0] 发布于 2009-07-14 20:29:00
用二维数组输出以下图形
0 1 1 1 1
-1 0 1 1 1
-1 -1 0 1 1
-1 -1 -1 0 1
-1 -1 -1 -1 0
回复列表 (共6个回复)
沙发
FFKK [专家分:1610] 发布于 2009-07-14 20:35:00
CLS
DIM A(5,5)
FOR I=1 TO 5
FOR J=1 TO 5
IF I>J THEN
A(I,J)=-1
ELSE
IF I<J THNE A(I,J)=1 ELSE A(I,J)=0
END IF
NEXT J
NEXT I
FOR I=1 TO 5
FOR J=1 TO 5
? A(I,J);
NEXT J
?
NEXT I
END
板凳
wzczxc [专家分:20] 发布于 2009-07-26 08:58:00
CLS
DIM A(5,5)
FOR I=1 TO 5
FOR J=1 TO 5
IF I>J THEN
A(I,J)=-1
ELSE
IF I<J THNE A(I,J)=1 ELSE A(I,J)=0
END IF
NEXT J
NEXT I
FOR I=1 TO 5
FOR J=1 TO 5
? A(I,J);
NEXT J
?
NEXT I
END
3 楼
qbasic爱好者 [专家分:10] 发布于 2009-08-01 10:48:00
一楼的,是then!
cls
input n
for i=1 to n
for j=1 to n
if i>j then print -1;
if i=j then print 0;
if i<j then print 1;
next j
print
next i
end
4 楼
梦幻小樱 [专家分:140] 发布于 2009-08-06 13:11:00
CLS
DIM A(5,5)
FOR I=1 TO 5
FOR J=1 TO 5
IF I>J THEN
A(I,J)=-1
ELSE
IF I<J THNE A(I,J)=1 ELSE A(I,J)=0
END IF
NEXT J
NEXT I
FOR I=1 TO 5
FOR J=1 TO 5
? A(I,J);
NEXT J
?
NEXT I
END
5 楼
phile [专家分:2310] 发布于 2009-08-06 19:13:00
CLS
FOR I=1 TO 5
FOR J=1 TO 5
IF I=J THEN
PRINT USING"###";0
ELSEIF I>J THEN
PRINT USING"###";-1
ELSE
PRINT USING"###";1
END IF
NEXT J
PRINT
NEXT I
6 楼
FFKK [专家分:1610] 发布于 2009-08-18 20:57:00
3楼的别逞强
CLS
FOR I=1 TO 5
DO
O=O+1
IF I>O THEN A(i,j)=-1
IF I<OTHEN A(i,J)=1
IF I=O THEN A(I,J)=0
LOOP UNTIL O=5
O=0.
NEXT I
FOR I=1 TO 5
FOR J=1 TO 5
? A(i,J);
NEXT J
?
NEXT J
END
我来回复