Skip to content

Commit 4a75b50

Browse files
authored
Update chapter-05-loops.md
1 parent 83ad7d2 commit 4a75b50

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

chapter-05-loops.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -298,64 +298,64 @@ After these changes the structure of the project should look like this:
298298

299299
For each subsequent exercise we will create a new class in the way described above.
300300

301-
### Задача: Елемент, равен на сумата на останалите
301+
### Problem: Element Equal to the Sum of the Rest
302302

303-
Да се напише програма, която въвежда **n цели числа** и проверява дали сред тях съществува число, което е равно на сумата на всички останали. Ако има такъв елемент, се отпечатва **"Yes" + неговата стойност**, в противен случай - **"No" + разликата между най-големия елемент и сумата на останалите** (по абсолютна стойност).
303+
Write a program that inputs **n whole numbers** and checks whether among them there is a number equal to the sum of all the rest. If there is such an element, print **"Yes" + its value**, otherwise - **"No" + the difference between the largest element and the sum of the rest** (by absolute value).
304304

305-
#### Примерен вход и изход
305+
#### Sample input and output
306306

307-
| Вход | Изход | Коментар |
307+
| Input | Output | Comments |
308308
| --- | --- | :---: |
309309
| 7<br>3<br>4<br>1<br>1<br>2<br>12<br>1 | Yes<br>Sum = 12 | 3 + 4 + 1 + 2 + 1 + 1 = 12 |
310310
| 4<br>6<br>1<br>2<br>3 | Yes<br>Sum = 6 | 1 + 2 + 3 = 6 |
311311
| 3<br>1<br>1<br>10 | No<br>Diff = 8 | &#124;10 - (1 + 1)&#124; = 8 |
312312
| 3<br>5<br>5<br>1 | No<br>Diff = 1 | &#124;5 - (5 + 1)&#124; = 1 |
313313
| 3<br>1<br>1<br>1 | No<br>Diff = 1 | - |
314314

315-
#### Насоки и подсказки
315+
#### Hints and Guidelines
316316

317-
Трябва да изчислим **сумата** на всички елементи, да намерим **най-големия** от тях и да проверим търсеното условие.
317+
We must calculate the **sum** of all elements, find the **largest** of them and check the condition.
318318

319-
#### Тестване в Judge системата
319+
#### Testing in the Judge system
320320

321-
Тествайте решението си тук: [https://judge.softuni.bg/Contests/Practice/Index/655#9](https://judge.softuni.bg/Contests/Practice/Index/655#9).
321+
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/655#9](https://judge.softuni.bg/Contests/Practice/Index/655#9).
322322

323323

324-
### Задача: четни / нечетни позиции
324+
### Problem: Odd / Even Position
325325

326-
Напишете програма, която чете **n числа** и пресмята **сумата**, **минимума** и **максимума** на числата на **четни** и **нечетни** позиции (броим от 1). Когато няма минимален / максимален елемент, отпечатайте **"No"**.
326+
Write a program that reads **n numbers** and calculates **the sum**, the **min** and **max** values of the numbers on **even** and **odd** positions (counted from 1). If there is no min / max element, print **"No"**.
327327

328-
#### Примерен вход и изход
328+
#### Sample input and output
329329

330-
| Вход | Изход | Вход | Изход |
330+
| Input | Output | Input | Output |
331331
| --- | --- | --- | --- |
332332
| 6<br>2<br>3<br>5<br>4<br>2<br>1 | OddSum=9,<br>OddMin=2,<br>OddMax=5,<br>EvenSum=8,<br>EvenMin=1,<br>EvenMax=4 | 2<br>1.5<br>-2.5 | OddSum=1.5,<br>OddMin=1.5,<br>OddMax=1.5,<br>EvenSum=-2.5,<br>EvenMin=-2.5,<br>EvenMax=-2.5 |
333333
| 1<br>1 | OddSum=1,<br>OddMin=1,<br>OddMax=1,<br>EvenSum=0,<br>EvenMin=No,<br>EvenMax=No | 0 | OddSum=0,<br>OddMin=No,<br>OddMax=No,<br>EvenSum=0,<br>EvenMin=No,<br>EvenMax=No |
334334
| 5<br>3<br>-2<br>8<br>11<br>-3 | OddSum=8,<br>OddMin=-3,<br>OddMax=8,<br>EvenSum=9,<br>EvenMin=-2,<br>EvenMax=11 | 4<br>1.5<br>1.75<br>1.5<br>1.75 | OddSum=3,<br>OddMin=1.5,<br>OddMax=1.5,<br>EvenSum=3.5,<br>EvenMin=1.75,<br>EvenMax=1.75 |
335335
| 1<br>-5 | OddSum=-5,<br>OddMin=-5,<br>OddMax=-5,<br>EvenSum=0,<br>EvenMin=No,<br>EvenMax=No | 3<br>-1<br>-2<br>-3 | OddSum=-4,<br>OddMin=-3,<br>OddMax=-1,<br>EvenSum=-2,<br>EvenMin=-2,<br>EvenMax=-2 |
336336

337-
#### Насоки и подсказки
337+
#### Hints and Guidelines
338338

339-
Задачата обединява няколко предходни задачи: намиране на **минимум**, **максимум** и **сума**, както и обработка на елементите от **четни и нечетни позиции**. Припомнете си ги.
339+
The task combines some of the previous tasks: finding the **min**, **max** and the **sum**, as well as processing elements on **even and odd positions**. Check your solutions of the previous tasks again.
340340

341-
В тази задача е по-добре да се работи с **дробни числа** (не цели). Сумата, минимумът и максимумът също са дробни числа. Трябва да използваме **неутрална начална стойност** при намиране на минимум / максимум, например **1000000000.0** и **-1000000000.0**. Ако получим накрая неутралната стойност, печатаме **“No”**.
341+
In the current task it is better to work with **fractions** (not integers). The sum, the min and the max value will also be fractions. We have to use **neutral starting value** in finding the min / max value, for example **1000000000.0** and **-1000000000.0**. If the end result is equal to the neutral value, we will print **“No”**.
342342

343-
#### Тестване в Judge системата
343+
#### Testing in the Judge system
344344

345-
Тествайте решението си тук: [https://judge.softuni.bg/Contests/Practice/Index/655#10](https://judge.softuni.bg/Contests/Practice/Index/655#10).
345+
Test your solution here: [https://judge.softuni.bg/Contests/Practice/Index/655#10](https://judge.softuni.bg/Contests/Practice/Index/655#10).
346346

347347

348-
### Задача: еднакви двойки
348+
### Problem: Equal Pairs
349349

350-
Дадени са **2 \* n числа**. Първото и второто формират **двойка**, третото и четвъртото също и т.н. Всяка двойка има **стойност**сумата от съставящите я числа. Напишете програма, която проверява **дали всички двойки имат еднаква стойност**.
350+
There are **2 \* n numbers**. The first and the second form a **pair**, the third and the fourth number also, and so on. Each pair has a **value**the sum of its numbers. Write a program that checks **if all pairs have equal values**.
351351

352-
В случай, че е еднаква отпечатайте **"Yes, value=…" + стойността**, в противен случай отпечатайте **максималната разлика** между две последователни двойки в следния формат - **"No, maxdiff=…" + максималната разлика**.
352+
In case the value is the same, print **"Yes, value=…" + the value**, otherwise print the **maximum difference** between two consecutive pairs in the following format - **"No, maxdiff=…" + the maximum difference**.
353353

354-
Входът се състои от число **n**, следвано от **2*n цели числа**, всички по едно на ред.
354+
The input consists of number **n**, followed by **2*n integers** one per line.
355355

356-
#### Примерен вход и изход
356+
#### Sample input and output
357357

358-
| Вход | Изход | Коментар |
358+
| Input | Output | Comments |
359359
| --- | --- | :---: |
360360
| 3<br>1<br>2<br>0<br>3<br>4<br>-1| Yes, value=3 | стойности = {3, 3, 3}<br>еднакви стойности |
361361
| 2<br>1<br>2<br>2<br>2 | No, maxdiff=1 | стойности = {3, 4}<br>разлики = {1}<br>макс. разлика = 1 |

0 commit comments

Comments
 (0)