Created
February 26, 2025 15:09
-
-
Save NevermindKT/46fcdd3422dce95770f05600fc31d454 to your computer and use it in GitHub Desktop.
dz6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1 | |
DECLARE @a SMALLINT = 1 | |
DECLARE @b SMALLINT = 2 | |
DECLARE @c SMALLINT = 3 | |
PRINT (@a + @b + @c) / 3 | |
-- 2 | |
DECLARE @var SMALLINT = 123 | |
PRINT LEN(CAST(@var AS VARCHAR)) | |
-- 3 | |
DECLARE @L SMALLINT = 30 | |
PRINT REPLICATE('*',@L) | |
-- 4 | |
DECLARE @time INT = DATEPART(HOUR,GETDATE()) | |
IF @time >= 6 AND @time < 18 | |
PRINT 'Сейчас день' | |
ELSE | |
PRINT 'Сейчас ночь' | |
-- 5 | |
DECLARE @N INT = 15, @i INT = 0, @Password NVARCHAR(15) = ''; | |
WHILE @i < @N | |
BEGIN | |
SET @Password = @Password + CAST(FLOOR(1 + (10 - 1) * RAND()) AS NVARCHAR); | |
SET @i += 1; | |
END | |
PRINT @Password; | |
======================= | |
-- 2 | |
DECLARE @string NVARCHAR(50) = 'One two tree', @i INT = 0, @count INT = 0 | |
WHILE @i < LEN(@string) | |
BEGIN | |
IF SUBSTRING(@string, @i, 1) = ' ' | |
SET @count += 1 | |
SET @i += 1 | |
END | |
PRINT @count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment