-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask5.html
More file actions
133 lines (133 loc) · 3.79 KB
/
task5.html
File metadata and controls
133 lines (133 loc) · 3.79 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home task 5</title>
<style>
h1{
text-align: center;
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: rgb(255, 151, 182);
}
.container{
display:flex;
flex-wrap: wrap;
justify-content: space-around;
background-color: rgb(255, 151, 182);
}
#max_elem, #factorial, #summ_arrays{
margin:10px;
background: rgb(255, 183, 183) ;
padding: 30px 5px;
}
#but{
background-color: antiquewhite;
border-color: antiquewhite;
border-radius: 5px;
padding-left: auto;
}
p{
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
#result,#result1,#result2 {
background-color: antiquewhite;
text-align: center;
}
</style>
</head>
<body>
<h1>Домашнее задание №5</h1>
<div class="container">
<div id="max_elem">
<p><b>Найти максимальный элемент массива</b> </p>
<p>
Введите массив: <input type="text" id="myArr" value="12, 0.4, 30, -2, 9.3" size="20">
</p>
<p>
<input type="button" id="but" value="Вычислить" onclick="maxElement()">
</p>
<div id="result1"></div></div>
<div id="factorial">
<p><b>Вычислить: C=(M!+N!)/(M+1)!</b></p>
<p>
Введите значение M: <input type="text" id="numM" value="4" size="10">
</p>
<p>
Введите значение N: <input type="text" id="numN" value="5" size="10">
</p>
<p>
<input type="button" id="but" value="Вычислить" onclick="formula()">
</p>
<div id="result"></div>
</div>
<div id="summ_arrays">
<p><b>Найти значение</b> </p>
<p><img src="images/capt.bmp" alt="" width="300px"></p>
<p>
Введите массив x: <input type="text" id="arrx" value="0.3, 5.2, 9.4, 8" size="20">
</p>
<p>
Введите массив y: <input type="text" id="arry" value="43, 5, 3.4, 8, 20" size="20">
</p>
<p>
<input type="button" id="but" value="Вычислить" onclick="summary()">
</p>
<div id="result2"></div>
</div></div>
<script>
function maxElement(){
let a=myArr.value;
let ar = a.split(", ");
let arr = ar.map(Number);
console.log(arr);
s="";
let max=arr[0];
for(let i = 0; i<arr.length; i++){
if(max < arr[i]){
max = arr[i];
}
}
s+=max;
result1.innerHTML=s;
}
function formula(){
m=Number(numM.value);
n=Number(numN.value);
r="";
C=new Number();
C=(factorial(n)+factorial(m))/factorial(m+1);
function factorial(n){
let f=1;
while(n) f*=n--;
return f;
}
r+=C;
result.innerHTML=r;}
function summary(){
let arr1=arrx.value;
let arr2=arry.value;
let x1=arr1.split(", ");
let x = x1.map(Number);
let y1=arr2.split(", ");
let y = y1.map(Number);
console.log(x);
console.log(y);
let sum=0;
let str="";
function sumElem(arr){
for (i = 0; i < arr.length; i++) {
sum += arr[i];
}
return sum;
}
console.log(sumElem(x));
console.log(sumElem(y));
C=(sumElem(x)+sumElem(y))/2;
str+=C.toFixed(2) ;
console.log(str);
result2.innerHTML=str;}
</script>
</body>
</html>