主题:简单题
08HQM
[专家分:60] 发布于 2007-11-03 12:44:00
编程打印如下图形。(当N=7时)
%
% %
% %
%$$$$$%
% $$$ %
% $ %
% $$$ %
%$$$$$%
% %
% %
%
回复列表 (共2个回复)
沙发
傲视人间 [专家分:60] 发布于 2007-11-03 12:45:00
CLS
INPUT N
M = N \ 2 + 1
FOR I = N TO 2 STEP -1
PRINT TAB(I); "%";
IF I <= M THEN
PRINT SPC((M - I) * 2); STRING$(I * 2 - 3, "$"); SPC((M - I) * 2);
ELSE
PRINT SPC((N - I) * 2 - 1);
END IF
IF I <> N THEN PRINT "%"
NEXT I
FOR I = 3 TO N
PRINT TAB(I); "%";
IF I <= M THEN
PRINT SPC((M - I) * 2); STRING$(I * 2 - 3, "$"); SPC((M - I) * 2);
ELSE
PRINT SPC((N - I) * 2 - 1);
END IF
IF I <> N THEN PRINT "%"
NEXT I
END
板凳
hxy_anhui [专家分:320] 发布于 2009-01-29 17:27:00
CLS
INPUT N
FOR I = N TO N – N \ 2 + 1 STEP -1
PRINT TAB(I); “%”; SPC(K * 2 - 1);
IF I <> N THEN PRINT “%”;
PRINT
K = K + 1
NEXT I
K = 0
FOR I = N \ 2 + 1 TO 2 STEP -1
PRINT TAB(I); “%”; SPC(K * 2); STRING$((I – 1) * 2 – 1, “$”); SPC(K * 2); “%”
K = K + 1
NEXT I
FOR I = 3 TO N \ 2 + 1
PRINT TAB(I); “%”; SPC((N \ 2 + 1 – I) * 2); STRING$((I – 1) * 2 – 1, “$”); SPC((N \ 2 + 1 – I) * 2); “%”
NEXT I
FOR I = N \ 2 + 2 TO N
PRINT TAB(I); “%”; SPC((N – I) * 2 – 1);
IF I <> N THEN PRINT “%”;
PRINT
NEXT I
END
我来回复