回 帖 发 新 帖 刷新版面

主题:请教各位大哥,有帮我的吗?

各位大哥好,请教一个初学者问题,如何输出下列图形,刚学   qb,见笑了
              *
             ***
            *****
           *******
            *****
             ***
              *

回复列表 (共12个回复)

沙发

do
input"n=":n
loop until n(13andn)1
for i=1 to n:print tab(21-1)
for j=1 to 2*i-1 : print"*";:next j : print : next
for i=n-1 to1 stop -1: print tab(21-i);
for j=1 to 2*i-1: print "*";:next j : print :next i
end

板凳

for i = 1 to 4
print tab(20-i);
k=2*i-1
for j =  1 to k
  print "*";
next j
next i
for i= 3 to 1 step -1
   print tab(20-i);
   k=2*i-1
   for j = 1 to  k
    print "*";
   next j
next i
end
你说你是刚学,我编的很简单你自己好好琢磨琢磨吧!

3 楼

谢了[em2]

4 楼

CLS
FOR i = 1 TO 4
  PRINT TAB(10 - i); STRING$(2 * i - 1, "*")
NEXT i
FOR i = 3 TO 1 STEP -1
  PRINT TAB(10 - i); STRING$(2 * i - 1, "*")
NEXT i

5 楼

input n
n=n-1
for i=-n to n
  p=abs(i)
  print tab(n-p)*2;
  for j=1 to (n-P)*2
   PRINT "*";
NEXT J
PRINT
NEXT I

  [em4]

6 楼


cls
for i=1 to 9
   print tab(abs(i-5)+30);
   a=2*(5-abs(i-5))-1
   for j=1 to a
       print"*";
   next j
   print
next i
end

7 楼

CLS
DO
  INPUT "N=",N
LOOP  UNTIL N MOD 2=1
FOR I=1 TO (N+1)/2
  FOR J=1 TO (N+1)/2-I
    PRINT " ";
  NEXT J
  FOR J=1 TO I
    PRINT "*";
  NEXT J
  PRINT
NEXT I
FOR I=(N-1)/2 TO 1 STEP -1
  FOR J=1 TO (N+1)/2-I    
    PRINT " ";
  NEXT J
  FOR J=1 TO I
    PRINT "*";
  NEXT J
  PRINT
NEXT I
END   

8 楼

用一个双重循环就可以了:
用到的知识点有:ABS(X),TAB(X) 函数
程序如下:
for i=1 to 7 
print tab(17+abs(i-4));   '控制每一行第一字符的位置
for j=1 to 7-2*abs(i-4)   '打印每一行的字符
 print "*";  
next j
print                '换行
next i
end

9 楼

CLS
INPUT N:M=N-1
FOR I=-M TO M
PRINT TAB(ABS(I)+1);
FOR J=1 TO (N-ABS(I-N))*2-1:PRINT "*";:NEXT J
PRINT
NEXT I
END

10 楼

cls
input n
m=n-1
for i=-m to m
print tab(abs(i)+1);
for j=1 to n-abs(i)*2
print "*";
next j:print
next i
end

我来回复

您尚未登录,请登录后再回复。点此登录或注册