主题:原创蛇形三角图形!最简单!
例如:
输入 ?4
输出:
1 3 6 10
2 5 9
4 8
7
主程序:
CLS
INPUT n
k = 2: h = 2: l = 1: b = 2: a = 1
FOR i = 1 TO n
FOR j = i TO n
PRINT a;
a = a + k: k = k + 1
NEXT j
PRINT
a = h: l = l + 1: h = h + l: b = b + 1: k = b
NEXT i
END
书上也有这一题的程序,但没有我的简便,就是变量多了点,其他都还好,对,是自创。
输入 ?4
输出:
1 3 6 10
2 5 9
4 8
7
主程序:
CLS
INPUT n
k = 2: h = 2: l = 1: b = 2: a = 1
FOR i = 1 TO n
FOR j = i TO n
PRINT a;
a = a + k: k = k + 1
NEXT j
a = h: l = l + 1: h = h + l: b = b + 1: k = b
NEXT i
END
书上也有这一题的程序,但没有我的简便,就是变量多了点,其他都还好,对,是自创。