三角形图案示例上述图案用于p(5)。如何使用mysql编写查询以打印模式p(n)(其中n是定义行数的整数),而不使用存储过程。我有一个mssqlserver的代码示例。
DECLARE @i INT = 20 WHILE (@i > 0) BEGIN PRINT REPLICATE('* ', @i) SET @i = @i - 1 END
v8wbuo2f1#
SET @NUMBER = 21; SELECT REPEAT('* ', @NUMBER := @NUMBER - 1) FROM information_schema.tables LIMIT 20;
或
SET @NUMBER = 21; SELECT REPEAT('* ', @NUMBER := @NUMBER - 1) FROM information_schema.tables WHERE @NUMBER > 1;
lhcgjxsq2#
SET @NUMBER = 21; SELECT REPEAT('* ', @NUMBER := @NUMBER - 1) FROM information_schema.tables;
2条答案
按热度按时间v8wbuo2f1#
或
lhcgjxsq2#