习惯受伤
随手写了一个,笑纳~~~declare @num int
declare @total int
declare @max int
declare @blank int
declare @temp int
declare @str varchar(max)
set @num = 1
set @total = 8
set @max = @total * 2 + 1 --max columns
set @str = '' --result str
while @num <= @total * 2 - 1 -- max star num
begin
set @temp = 0
set @blank = (@max - @num) / 2
--concat left blank
while(@temp < @blank)
begin
set @str = @str + ' '
set @temp = @temp + 1
end
set @temp = 0
--concat star
while(@temp < @num)
begin
set @str = @str + '*'
set @temp = @temp + 1
end
--concat '\r'
set @str = @str + CHAR(13)
set @num = @num + 2
end
print @str截图看看: