' Работа с палитрой
DECLARE SUB SETRGB (Cv%, R%, G%, b%)
DECLARE SUB SCRN9PAL (Cv%, R%, G%, b%)
DEFDBL A-Z
CONST Pi = 3.14159265358#, Rad = 180 / Pi, Gr = Pi / 180
CONST Aspect1 = 1.333333333333333#
CONST Aspect2 = 1.828571425714257#
CLS ' Ввод сторон
Again: PRINT "Vvedite storoni treugolnika."
1 INPUT " Vvedite storonu A : ", a
IF a < 0 GOTO 1
2 INPUT " Vvedite storonu B : ", b
IF b < 0 GOTO 2
3 INPUT " Vvedite storonu C : ", c
IF c < 0 GOTO 3
' Проверка на существование треугольника
IF ((a + b) <= c) OR ((a + c) <= b) OR ((b + c) <= a) GOTO Again
PRINT "Treugolnik:"
' Вывод типа треугольника
COLOR 10
IF a = b AND a = c AND b = c THEN PRINT "Ravnostoronnij"
IF a = b OR a = c OR b = c THEN PRINT "Ravnobedrennyj"
IF a * a + b * b = c * c OR a * a + c * c = b * b OR b * b + c * c = a * a THEN
PRINT "Pryamougolnij"
END IF: COLOR 7
' Сортировка сторон
IF a < b THEN SWAP a, b
IF b < c THEN SWAP b, c
IF a < b THEN SWAP a, b
PRINT "Sorting..."
PRINT "A ="; a
PRINT "B ="; b
PRINT "C ="; c
PRINT STRING$(80, 196)
Ug1 = a ^ 2 * Pi / (a ^ 2 + b ^ 2 + c ^ 2)
Ug2 = b ^ 2 * Pi / (a ^ 2 + b ^ 2 + c ^ 2)
Ug3 = c ^ 2 * Pi / (a ^ 2 + b ^ 2 + c ^ 2)
SummaUglov = Ug1 + Ug2 + Ug3
PRINT USING "Ug BC = ###.##"; Ug1 * Rad
PRINT USING "Ug AC = ###.##"; Ug2 * Rad
PRINT USING "Ug AB = ###.##"; Ug3 * Rad
PRINT USING "Summa uglov = ### "; SummaUglov * Rad
COLOR 15: PRINT "[ Press ENTER ] for draw triangle in mode:"
Regm = 1
WHILE Kb$ <> CHR$(13)
Kb$ = INKEY$
IF Kb$ = CHR$(0) + CHR$(80) THEN Regm = 2
IF Kb$ = CHR$(0) + CHR$(72) THEN Regm = 1
IF Regm = 1 THEN COLOR 15, 1 ELSE COLOR 7, 0
LOCATE 20, 3: PRINT "SCREEN 12 (640x480) Bad for eyes"
IF Regm = 2 THEN COLOR 15, 1 ELSE COLOR 7, 0
LOCATE 21, 3: PRINT "SCREEN 9 (640x350) With Page Reflection"
WEND
IF Regm = 1 THEN Asp = Aspect1: SCREEN 12
IF Regm = 2 THEN Asp = Aspect2: SCREEN 9, , 1, 0
Ug = Ug2: Tolst = a / 200
x1 = -a / 2: y1 = 0
x2 = a / 2: y2 = 0
MshX = a / 15
MshY = (a * Asp) / 15
WINDOW (x1 - MshX, -MshY)-(x2 + MshX, x2 * 2 / Asp + MshY)
Rd = 1
IF Regm = 2 THEN
SCRN9PAL 15, 2, 8, 31
SCRN9PAL 14, 63, 63, 30
ELSEIF Regm = 1 THEN
SETRGB 15, 2, 8, 31
SETRGB 14, 63, 63, 30
END IF
DO
Kb$ = INKEY$
IF Kb$ = CHR$(0) + CHR$(75) THEN Ug = Ug + 1 * Gr: Rd = 1 'Лево
IF Kb$ = CHR$(0) + CHR$(77) THEN Ug = Ug - 1 * Gr: Rd = 1 'Право
IF Rd = 1 THEN
Rd = 0
LINE (x1 - MshX, -MshY)-(x2 + MshX, x2 * 2 / Asp + MshY), 15, BF
COLOR 10
LOCATE 1, 1: PRINT USING "Ugol = ###.##"; Ug * Rad
PRINT "[" + CHR$(27) + "]" + "[" + CHR$(26) + "]" + " Ugol control"
x3 = x2 - COS(Ug) * c: y3 = y2 + SIN(Ug) * c
CIRCLE (x1, y1), .2, 10
CIRCLE (x2, y2), .2, 10
CIRCLE (x3, y3), .2, 10
FOR i = 0 TO Pi * 2 STEP .05
xk = SIN(i) * Tolst: yk = COS(i) * Tolst
LINE (x1 + xk, y1 + yk)-(x2 + xk, y2 + yk), 14
LINE (x1 + xk, y1 + yk)-(x3 + xk, y3 + yk), 14
LINE (x2 + xk, y2 + yk)-(x3 + xk, y3 + yk), 14
NEXT
IF Regm = 2 THEN PCOPY 1, 0
END IF
LOOP UNTIL Kb$ = CHR$(27)
SUB SCRN9PAL (Cv%, R%, G%, b%)
IF Cv% < 6 AND Cv% > -1 THEN SETRGB Cv%, R%, G%, b%
IF Cv% = 6 THEN SETRGB 20, R%, G%, b%
IF Cv% = 7 THEN SETRGB 7, R%, G%, b%
IF Cv% > 7 AND Cv% < 16 THEN SETRGB Cv% + 48, R%, G%, b%
END SUB
SUB SETRGB (Cv%, R%, G%, b%)
OUT &H3C8, Cv%: OUT &H3C9, R%: OUT &H3C9, G%: OUT &H3C9, b%
END SUB
Тестирование выполнено в программе QB64 ( Скачать )