January 14, 2014 at 9:44 am
DECLARE @NUMBER INT = 10
DECLARE @data CHAR(1)='#'
DECLARE @OTHERDATA CHAR(1)='@'
DECLARE @SPACEDATA CHAR(1)=' '
DECLARE @TEXT VARCHAR(MAX)
DECLARE @LEFT INT
DECLARE @RIGHT INT = 1
DECLARE @TEXTRIGHT INT
WHILE(@NUMBER>0)
BEGIN
SET @TEXT =''
SET @TEXTRIGHT = @RIGHT
IF(@NUMBER%2=0)
BEGIN
SET @LEFT = FLOOR(@NUMBER/2)
END
ELSE
BEGIN
SET @NUMBER = @NUMBER - 1
CONTINUE
END
WHILE(@LEFT>0)
BEGIN
IF(@LEFT>1)
BEGIN
SET @TEXT += @SPACEDATA
END
ELSE
BEGIN
WHILE(@TEXTRIGHT>0)
BEGIN
IF(@TEXTRIGHT%2=0)
SET @TEXT += @OTHERDATA
ELSE
SET @TEXT += @data
SET @TEXTRIGHT = @TEXTRIGHT - 1
END
PRINT(@TEXT)
END
SET @LEFT = @LEFT - 1
END
SET @NUMBER = @NUMBER - 1
IF(@RIGHT=1)
BEGIN
SET @RIGHT = 3
END
ELSE
BEGIN
SET @RIGHT = 2+@RIGHT
END
END
rkaram
January 14, 2014 at 9:51 am
can't really predict the output, since this poll has all incorrect answers.
kudos for the easily copy-and-pasteable code, it produces results that basically looks like a christmas tree, i guess.
but the results are 5 lines that don't appear in your poll
#
#@#
#@#@#
#@#@#@#
#@#@#@#@#
Lowell
January 14, 2014 at 10:10 am
Polls won't allow multi-line answers, but it's a nice output 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply