-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
174 lines (127 loc) · 3.71 KB
/
scripts.js
File metadata and controls
174 lines (127 loc) · 3.71 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
result = +prompt(`Номер задачи`);
switch(result) {
case 1:
first_velocity = 36;
second_velocity = first_velocity*1000/3600;
console.log(`${first_velocity} км/ч соответствует ${second_velocity} м/с.`)
first_velocity = 20;
second_velocity = first_velocity/1000*3600;
console.log(`${first_velocity} м/с соответствует ${second_velocity} км/ч.`)
break
case 2:
a = +prompt(`AB`)
b = +prompt(`BC`)
c = +prompt(`AC`)
p = a+b+c;
if (((a+b)>c) && ((c+b)>a) && ((a+c)>b)){
console.log(`треугольник существует`)
console.log(`периметр = ${p}`)
console.log(`площадь = ${Math.sqrt(p*(p-a)*(p-b)*(p-c))}`)
console.log(`соотношение = ${p/Math.sqrt(p*(p-a)*(p-b)*(p-c))}`)
}
else{
console.log(`треугольник не существует`)
}
break
case 3:
number = 1.2;
while((number % 1) > 0)
{
number = +prompt(`Введите число`)
}
i = 0
while(i<=number){
if (((i % 5) === 0) & (i!==0))
{
console.log(`${i} fizz buzz`)
}
if(i % 2 !== 0){
console.log(`${i} buzz`)
}
else{
console.log(`${i} fizz`)
}
i++
}
break
case 4:
string = ``;
for(i = 1; i <= 12; i++){
if(i % 2 === 0){
for(k = 1; k <= i; k++){
string +=`#`;
}
string +=`\n`;
}
else{
for(k = 1; k <= i; k++){
string +=`*`;
}
string +=`\n`;
}
}
string += `||||`
console.log(string)
break
case 5:
a = 1355
b = 5.45
c = 37
do{
b = prompt(`Введите число`)
b = +b
c = b - a;
if(c > 0){
console.log(`ваше число больше`)
}
if(c < 0){
console.log(`ваше число меньше`)
}
} while(c !== 0)
console.log(`Угадано`)
break
case 6:
n = 0
x = 0
y = 0
while(x*y*n <= 0)
{
alert(`Введите целые числа`)
n = +prompt(`Число`)
x = +prompt(`Возможный делитель 1`)
y = +prompt(`Возможный делитель 2`)
}
if ((n % x === 0) & (n % y === 0)){
check = true;
console.log(`n = ${n}, x = ${x}, y = ${y} = ${check}`)
}
else{
check = false;
console.log(`n = ${n}, x = ${x}, y = ${y} = ${check}`)
}
break;
case 7:
month = 0;
while(month < 1 || month > 12 || month === NaN)
{
alert(`Задайте число от 1 до 12`)
month = +prompt(`Номер месяца`)
}
if( month <= 3){
quarter = 1;
}
if( month > 3 || month <= 6){
quarter = 2;
}
if( month > 6 || month <= 9){
quarter = 3;
}
if( month > 9 || month <= 12){
quarter = 4;
}
console.log(`месяц ${month} => ${quarter} квартал `)
break
default:
result = prompt(`Номер задачи`, '');
break
}