-
Notifications
You must be signed in to change notification settings - Fork 0
/
triangle.html
104 lines (67 loc) · 3.55 KB
/
triangle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<body>
<h2>Координаты точек</h2>
<form>
<label for="firstX"> X для точки А:</label><br>
<input type="text" id="firstX"><br>
<label for="firstY"> Y для точки А:</label><br>
<input type="text" id="firstY"><br><br>
<label for="secondX"> X для точки В:</label><br>
<input type="text" id="secondX"><br>
<label for="second"> Y для точки В:</label><br>
<input type="text" id="secondY"><br><br>
<label for="thirdX"> X для точки С:</label><br>
<input type="text" id="thirdX"><br>
<label for="thirdY"> Y для точки С:</label><br>
<input type="text" id="thirdY"><br><br>
</form>
<button onclick="resolve()">Выполнить</button>
<br>
<br>
<script>
function resolve() {
const xForA = Number(document.getElementById("firstX").value);
const yForA = Number(document.getElementById("firstY").value);
const xForB = Number(document.getElementById("secondX").value);
const yForB = Number(document.getElementById("secondY").value);
const xForC = Number(document.getElementById("thirdX").value);
const yForC = Number(document.getElementById("thirdY").value);
let AB;
let BC;
let AC;
AB = Math.sqrt(Math.pow((xForA - xForB), 2) + Math.pow((yForA - yForB), 2));
BC = Math.sqrt(Math.pow((xForB - xForC), 2) + Math.pow((yForB - yForC), 2));
AC = Math.sqrt(Math.pow((xForA - xForC), 2) + Math.pow((yForA - yForC), 2));
AB == AC && AB == BC ? document.body.appendChild(document.createTextNode("Треугольник равносторонний ")) : document.body.appendChild(document.createTextNode("Треугольник не равносторонний "));
document.body.appendChild(document.createElement("br"));
//document.body.appendChild(document.createElement("br"));
AB == AC || AB == BC || AC == BC ? document.body.appendChild(document.createTextNode("Треугольник равнобедренный ")) : document.body.appendChild(document.createTextNode("Треугольник не равнобедренный "));
document.body.appendChild(document.createElement("br"));
//document.body.appendChild(document.createElement("br"));
const triangls = [AB, BC, AC];
const sorted = triangls.sort();
Math.pow(sorted[2], 2) == Math.pow(sorted[0], 2) + Math.pow(sorted[1], 2) ? console.log("Треугольник прямоугольный ") : console.log("Треугольник не прямоугольный ");
//console.log(AB);
document.body.appendChild(document.createTextNode("Длина стороны AB: " + AB));
document.body.appendChild(document.createElement("br"));
//console.log(BC);
document.body.appendChild(document.createTextNode("Длина стороны BC: " + BC));
document.body.appendChild(document.createElement("br"));
//console.log(AC);
document.body.appendChild(document.createTextNode("Длина стороны AC: " + AC));
document.body.appendChild(document.createElement("br"));
const perimetr = AB + BC + AC;
//console.log(perimetr);
document.body.appendChild(document.createTextNode("Периметр треугольника: " + perimetr));
document.body.appendChild(document.createElement("br"));
document.body.appendChild(document.createTextNode("Все чётные числа от 0 до величины периметра треугольника включительно: "));
document.body.appendChild(document.createElement("br"));
for(let i = 0; i <= perimetr; i += 2) {
//console.log(i);
document.body.appendChild(document.createTextNode(i));
document.body.appendChild(document.createElement("br"));
}
};
</script>
</body>