diff options
sem 8
51 files changed, 339 insertions, 196 deletions
| -rw-r--r-- | Sem. 01/Variables.cpp (renamed from Sem. 1/Variables.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 02/Even_Odd.cpp (renamed from Sem. 2/Even_Odd.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 02/Grades.cpp (renamed from Sem. 2/Grades.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 02/Operators_priority.png (renamed from Sem. 2/Operators_priority.png) | bin | 22886 -> 22886 bytes | |||
| -rw-r--r-- | Sem. 02/dayOfWeek.cpp (renamed from Sem. 2/dayOfWeek.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 02/isPrime_between[1,9].cpp (renamed from Sem. 2/isPrime_between[1,9].cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Contains5.cpp (renamed from Sem. 3/Contains5.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/DevidersCount_PrimalityCheck.cpp (renamed from Sem. 3/DevidersCount_PrimalityCheck.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/GCD_solution1.cpp (renamed from Sem. 3/GCD_solution1.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/GCD_solution2.cpp (renamed from Sem. 3/GCD_solution2.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/GCD_solution3_Eucid.cpp (renamed from Sem. 3/GCD_solution3_Eucid.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/PrintEvenNumbers.cpp (renamed from Sem. 3/PrintEvenNumbers.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/SumOfDigits.cpp (renamed from Sem. 3/SumOfDigits.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/01. Between100and200.cpp (renamed from Sem. 3/Tasks and Solutions/01. Between100and200.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/02. Speed check.cpp (renamed from Sem. 3/Tasks and Solutions/02. Speed check.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/03. Figures.cpp (renamed from Sem. 3/Tasks and Solutions/03. Figures.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/04. Time + 15.cpp (renamed from Sem. 3/Tasks and Solutions/04. Time + 15.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/05. Chainsaw.cpp (renamed from Sem. 3/Tasks and Solutions/05. Chainsaw.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/06. DivBy3.cpp (renamed from Sem. 3/Tasks and Solutions/06. DivBy3.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp (renamed from Sem. 3/Tasks and Solutions/07. ContainsDigit.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp (renamed from Sem. 3/Tasks and Solutions/08. DuplicateDigits.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp (renamed from Sem. 3/Tasks and Solutions/09. SumFromKtoN.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/10. Pyramid.cpp (renamed from Sem. 3/Tasks and Solutions/10. Pyramid.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/11. Clock.cpp (renamed from Sem. 3/Tasks and Solutions/11. Clock.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp (renamed from Sem. 3/Tasks and Solutions/12. ClockWithStart.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp (renamed from Sem. 3/Tasks and Solutions/13. ClockWithStartAndEnd.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/14. Frame.cpp (renamed from Sem. 3/Tasks and Solutions/14. Frame.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 03/Tasks and Solutions/tasks.pdf (renamed from Sem. 3/Tasks and Solutions/tasks.pdf) | bin | 449792 -> 449792 bytes | |||
| -rw-r--r-- | Sem. 04/README.md (renamed from Sem. 4/README.md) | 258 | ||||
| -rw-r--r-- | Sem. 04/Task1.cpp (renamed from Sem. 4/Task1.cpp) | 26 | ||||
| -rw-r--r-- | Sem. 04/Task2.cpp (renamed from Sem. 4/Task2.cpp) | 32 | ||||
| -rw-r--r-- | Sem. 04/Task3.cpp (renamed from Sem. 4/Task3.cpp) | 18 | ||||
| -rw-r--r-- | Sem. 04/Task4.cpp (renamed from Sem. 4/Task4.cpp) | 18 | ||||
| -rw-r--r-- | Sem. 04/bitwise_examples.cpp (renamed from Sem. 4/bitwise_examples.cpp) | 40 | ||||
| -rw-r--r-- | Sem. 05/README.md (renamed from Sem. 5/README.md) | 0 | ||||
| -rw-r--r-- | Sem. 05/Task 1.cpp (renamed from Sem. 5/Task 1.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 05/Task 2.cpp (renamed from Sem. 5/Task 2.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 05/Task 3.cpp (renamed from Sem. 5/Task 3.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 05/Task 4.cpp (renamed from Sem. 5/Task 4.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 05/Task 5.cpp (renamed from Sem. 5/Task 5.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 05/Task 6.cpp (renamed from Sem. 5/Task 6.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 06/README.md (renamed from Sem. 6/README.md) | 0 | ||||
| -rw-r--r-- | Sem. 06/Task_1(with functions).cpp (renamed from Sem. 6/Task_1(with functions).cpp) | 0 | ||||
| -rw-r--r-- | Sem. 06/Task_1(without functions).cpp (renamed from Sem. 6/Task_1(without functions).cpp) | 0 | ||||
| -rw-r--r-- | Sem. 06/Tasks_2,3,4,5,6,7,8,9,10.cpp (renamed from Sem. 6/Tasks_2,3,4,5,6,7,8,9,10.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 07/BullsAndColls.cpp (renamed from Sem. 7/BullsAndColls.cpp) | 0 | ||||
| -rw-r--r-- | Sem. 07/README.md (renamed from Sem. 7/README.md) | 0 | ||||
| -rw-r--r-- | Sem. 08/README.md | 35 | ||||
| -rw-r--r-- | Sem. 08/task1.cpp | 17 | ||||
| -rw-r--r-- | Sem. 08/task2.cpp | 42 | ||||
| -rw-r--r-- | Sem. 08/task3.cpp | 49 |
diff --git a/Sem. 1/Variables.cpp b/Sem. 01/Variables.cpp index f793a65..f793a65 100644 --- a/Sem. 1/Variables.cpp +++ b/Sem. 01/Variables.cpp diff --git a/Sem. 2/Even_Odd.cpp b/Sem. 02/Even_Odd.cpp index 89c2ecd..89c2ecd 100644 --- a/Sem. 2/Even_Odd.cpp +++ b/Sem. 02/Even_Odd.cpp diff --git a/Sem. 2/Grades.cpp b/Sem. 02/Grades.cpp index 18e1538..18e1538 100644 --- a/Sem. 2/Grades.cpp +++ b/Sem. 02/Grades.cpp diff --git a/Sem. 2/Operators_priority.png b/Sem. 02/Operators_priority.png Binary files differindex 07d2565..07d2565 100644 --- a/Sem. 2/Operators_priority.png +++ b/Sem. 02/Operators_priority.png diff --git a/Sem. 2/dayOfWeek.cpp b/Sem. 02/dayOfWeek.cpp index b9640c3..b9640c3 100644 --- a/Sem. 2/dayOfWeek.cpp +++ b/Sem. 02/dayOfWeek.cpp diff --git a/Sem. 2/isPrime_between[1,9].cpp b/Sem. 02/isPrime_between[1,9].cpp index 08d8445..08d8445 100644 --- a/Sem. 2/isPrime_between[1,9].cpp +++ b/Sem. 02/isPrime_between[1,9].cpp diff --git a/Sem. 3/Contains5.cpp b/Sem. 03/Contains5.cpp index 78d13f0..78d13f0 100644 --- a/Sem. 3/Contains5.cpp +++ b/Sem. 03/Contains5.cpp diff --git a/Sem. 3/DevidersCount_PrimalityCheck.cpp b/Sem. 03/DevidersCount_PrimalityCheck.cpp index 7584722..7584722 100644 --- a/Sem. 3/DevidersCount_PrimalityCheck.cpp +++ b/Sem. 03/DevidersCount_PrimalityCheck.cpp diff --git a/Sem. 3/GCD_solution1.cpp b/Sem. 03/GCD_solution1.cpp index 58ea35b..58ea35b 100644 --- a/Sem. 3/GCD_solution1.cpp +++ b/Sem. 03/GCD_solution1.cpp diff --git a/Sem. 3/GCD_solution2.cpp b/Sem. 03/GCD_solution2.cpp index ba06c89..ba06c89 100644 --- a/Sem. 3/GCD_solution2.cpp +++ b/Sem. 03/GCD_solution2.cpp diff --git a/Sem. 3/GCD_solution3_Eucid.cpp b/Sem. 03/GCD_solution3_Eucid.cpp index f190a90..f190a90 100644 --- a/Sem. 3/GCD_solution3_Eucid.cpp +++ b/Sem. 03/GCD_solution3_Eucid.cpp diff --git a/Sem. 3/PrintEvenNumbers.cpp b/Sem. 03/PrintEvenNumbers.cpp index e9a2231..e9a2231 100644 --- a/Sem. 3/PrintEvenNumbers.cpp +++ b/Sem. 03/PrintEvenNumbers.cpp diff --git a/Sem. 3/SumOfDigits.cpp b/Sem. 03/SumOfDigits.cpp index 6777a42..6777a42 100644 --- a/Sem. 3/SumOfDigits.cpp +++ b/Sem. 03/SumOfDigits.cpp diff --git a/Sem. 3/Tasks and Solutions/01. Between100and200.cpp b/Sem. 03/Tasks and Solutions/01. Between100and200.cpp index 0817bcc..0817bcc 100644 --- a/Sem. 3/Tasks and Solutions/01. Between100and200.cpp +++ b/Sem. 03/Tasks and Solutions/01. Between100and200.cpp diff --git a/Sem. 3/Tasks and Solutions/02. Speed check.cpp b/Sem. 03/Tasks and Solutions/02. Speed check.cpp index 4660382..4660382 100644 --- a/Sem. 3/Tasks and Solutions/02. Speed check.cpp +++ b/Sem. 03/Tasks and Solutions/02. Speed check.cpp diff --git a/Sem. 3/Tasks and Solutions/03. Figures.cpp b/Sem. 03/Tasks and Solutions/03. Figures.cpp index 170c403..170c403 100644 --- a/Sem. 3/Tasks and Solutions/03. Figures.cpp +++ b/Sem. 03/Tasks and Solutions/03. Figures.cpp diff --git a/Sem. 3/Tasks and Solutions/04. Time + 15.cpp b/Sem. 03/Tasks and Solutions/04. Time + 15.cpp index aee3118..aee3118 100644 --- a/Sem. 3/Tasks and Solutions/04. Time + 15.cpp +++ b/Sem. 03/Tasks and Solutions/04. Time + 15.cpp diff --git a/Sem. 3/Tasks and Solutions/05. Chainsaw.cpp b/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp index 68940e0..68940e0 100644 --- a/Sem. 3/Tasks and Solutions/05. Chainsaw.cpp +++ b/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp diff --git a/Sem. 3/Tasks and Solutions/06. DivBy3.cpp b/Sem. 03/Tasks and Solutions/06. DivBy3.cpp index 044aee9..044aee9 100644 --- a/Sem. 3/Tasks and Solutions/06. DivBy3.cpp +++ b/Sem. 03/Tasks and Solutions/06. DivBy3.cpp diff --git a/Sem. 3/Tasks and Solutions/07. ContainsDigit.cpp b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp index 4ae1131..4ae1131 100644 --- a/Sem. 3/Tasks and Solutions/07. ContainsDigit.cpp +++ b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp diff --git a/Sem. 3/Tasks and Solutions/08. DuplicateDigits.cpp b/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp index 0fa5946..0fa5946 100644 --- a/Sem. 3/Tasks and Solutions/08. DuplicateDigits.cpp +++ b/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp diff --git a/Sem. 3/Tasks and Solutions/09. SumFromKtoN.cpp b/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp index aea318a..aea318a 100644 --- a/Sem. 3/Tasks and Solutions/09. SumFromKtoN.cpp +++ b/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp diff --git a/Sem. 3/Tasks and Solutions/10. Pyramid.cpp b/Sem. 03/Tasks and Solutions/10. Pyramid.cpp index 5d9e2a9..5d9e2a9 100644 --- a/Sem. 3/Tasks and Solutions/10. Pyramid.cpp +++ b/Sem. 03/Tasks and Solutions/10. Pyramid.cpp diff --git a/Sem. 3/Tasks and Solutions/11. Clock.cpp b/Sem. 03/Tasks and Solutions/11. Clock.cpp index 6386ca0..6386ca0 100644 --- a/Sem. 3/Tasks and Solutions/11. Clock.cpp +++ b/Sem. 03/Tasks and Solutions/11. Clock.cpp diff --git a/Sem. 3/Tasks and Solutions/12. ClockWithStart.cpp b/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp index 1b996e1..1b996e1 100644 --- a/Sem. 3/Tasks and Solutions/12. ClockWithStart.cpp +++ b/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp diff --git a/Sem. 3/Tasks and Solutions/13. ClockWithStartAndEnd.cpp b/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp index af39745..af39745 100644 --- a/Sem. 3/Tasks and Solutions/13. ClockWithStartAndEnd.cpp +++ b/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp diff --git a/Sem. 3/Tasks and Solutions/14. Frame.cpp b/Sem. 03/Tasks and Solutions/14. Frame.cpp index 92de3ca..92de3ca 100644 --- a/Sem. 3/Tasks and Solutions/14. Frame.cpp +++ b/Sem. 03/Tasks and Solutions/14. Frame.cpp diff --git a/Sem. 3/Tasks and Solutions/tasks.pdf b/Sem. 03/Tasks and Solutions/tasks.pdf Binary files differindex 6c2ad50..6c2ad50 100644 --- a/Sem. 3/Tasks and Solutions/tasks.pdf +++ b/Sem. 03/Tasks and Solutions/tasks.pdf diff --git a/Sem. 4/README.md b/Sem. 04/README.md index 5357d01..9ce9f75 100644 --- a/Sem. 4/README.md +++ b/Sem. 04/README.md @@ -1,129 +1,129 @@ -**Десетична бройна система.**
-
-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 , 12
-
-Защото използваме 10 символа: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
-
-Най-малката бройна система: **Единична бройна система (Unary)**
-
-Символи: 1
-
-1 = 1
-
-2 = 11
-
-3 = 111
-
-4 = 1111
-
-5 = 11111
-
-6 = 111111
-
-
-**Двоична бройна система (binary)**
-
-Символи: 0,1
-
-0 - 00000
-
-1 - 00001
-
-2 - 00010
-
-3 - 00011
-
-4 - 00100
-
-5 - 00101
-
-6 - 00110
-
-**Троична бройна система**
-
-Символи: 0, 1, 2
-
-0 - 00
-
-1 - 01
-
-2 - 02
-
-3 - 10
-
-4 - 11
-
-5 - 12
-
-6 - 20
-
-
-Пребобрзвуане между бройни системи.
-
-**1. Десетична бройна система -> k-ична(k = 2(двоична), k = 3(троична), k = 10(десетична)) бройна система.**
-
-**Пример 1**: Преобразуване на числото 36 от десетична бройна система в двоична бройна система.
-
-Т.е k = 2.
-
-| | | %k |
-|----|--------|----|
-| | n = 36 | 0 |
-| /k | 18 | 0 |
-| /k | 9 | 1 |
-| /k | 4 | 0 |
-| /k | 2 | 0 |
-| /k | 1 | 1 |
-| /k | 0 | |
-
-
-**Гледаме от долу нагоре - 100100**
-
-**Пример 2**: Преобразуване на числото 38 от десетична бройна система в троична бройна система.
-
-Т.е k = 3.
-
-| | | %k |
-|----|--------|----|
-| | n = 38 | 2 |
-| /k | 12 | 0 |
-| /k | 4 | 1 |
-| /k | 1 | 1 |
-| /k | 0 | |
-
-**Гледаме от долу нагоре - 1102**
-
-**1. k-ична бройна система -> десетична бройна система.**
-
-**Пример 3**: Преобразуване на числото 100100 от двоична бройна система в десетична бройна система.
-
-0*2^0 + 0*2^1 + 1*2^2 + 0*2^3 + 0*2^4 + 1*2^5 = 4 + 32 = 36
-
-**Пример 4**: Преобразуване на числото 1102 от троична бройна система в десетична бройна система
-
-2*3^0 + 0*3^1 + 1*3^2 + 1*3^3 = 2 + 9 + 27 = 38.
-
-
-Всяка една променлива има **фиксиран** размер - памет, която заема.
-
-int - 32 бита. бит - 0 или 1
-
-sizeof(int) - > 4 размер в байтове. Байт = 8 бита.
-
-Първият бит в int-а определя знака.
-
-Минимална стойност на променлива от тип int: -2^31.
-
-Максимална стоиност на променлива от тип int: 2^31 - 1
-
-Побитови операции: Виж **bitwise_examples.cpp**
-
-Побитови операции(задачи):
-
-**Задача 1**: Да се провери дали дадено число е четно или нечетно.
-
-**Задача 2**: Въвежда се числa n и k и да се определи стойността на k-тия бит.(Вход: 10, 2 (000..001010) Изход: 0)
-
-**Задача 3**: Въвежда се число n. Да се пресметне 2^n.
-
-**Задача 4**: Въвежда се число n. Да се пресметне числото закодирано в предпоследните 3 бита.
+**Десетична бройна система.** + +1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 , 12 + +Защото използваме 10 символа: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + +Най-малката бройна система: **Единична бройна система (Unary)** + +Символи: 1 + +1 = 1 + +2 = 11 + +3 = 111 + +4 = 1111 + +5 = 11111 + +6 = 111111 + + +**Двоична бройна система (binary)** + +Символи: 0,1 + +0 - 00000 + +1 - 00001 + +2 - 00010 + +3 - 00011 + +4 - 00100 + +5 - 00101 + +6 - 00110 + +**Троична бройна система** + +Символи: 0, 1, 2 + +0 - 00 + +1 - 01 + +2 - 02 + +3 - 10 + +4 - 11 + +5 - 12 + +6 - 20 + + +Пребобрзвуане между бройни системи. + +**1. Десетична бройна система -> k-ична(k = 2(двоична), k = 3(троична), k = 10(десетична)) бройна система.** + +**Пример 1**: Преобразуване на числото 36 от десетична бройна система в двоична бройна система. + +Т.е k = 2. + +| | | %k | +|----|--------|----| +| | n = 36 | 0 | +| /k | 18 | 0 | +| /k | 9 | 1 | +| /k | 4 | 0 | +| /k | 2 | 0 | +| /k | 1 | 1 | +| /k | 0 | | + + +**Гледаме от долу нагоре - 100100** + +**Пример 2**: Преобразуване на числото 38 от десетична бройна система в троична бройна система. + +Т.е k = 3. + +| | | %k | +|----|--------|----| +| | n = 38 | 2 | +| /k | 12 | 0 | +| /k | 4 | 1 | +| /k | 1 | 1 | +| /k | 0 | | + +**Гледаме от долу нагоре - 1102** + +**1. k-ична бройна система -> десетична бройна система.** + +**Пример 3**: Преобразуване на числото 100100 от двоична бройна система в десетична бройна система. + +0*2^0 + 0*2^1 + 1*2^2 + 0*2^3 + 0*2^4 + 1*2^5 = 4 + 32 = 36 + +**Пример 4**: Преобразуване на числото 1102 от троична бройна система в десетична бройна система + +2*3^0 + 0*3^1 + 1*3^2 + 1*3^3 = 2 + 9 + 27 = 38. + + +Всяка една променлива има **фиксиран** размер - памет, която заема. + +int - 32 бита. бит - 0 или 1 + +sizeof(int) - > 4 размер в байтове. Байт = 8 бита. + +Първият бит в int-а определя знака. + +Минимална стойност на променлива от тип int: -2^31. + +Максимална стоиност на променлива от тип int: 2^31 - 1 + +Побитови операции: Виж **bitwise_examples.cpp** + +Побитови операции(задачи): + +**Задача 1**: Да се провери дали дадено число е четно или нечетно. + +**Задача 2**: Въвежда се числa n и k и да се определи стойността на k-тия бит.(Вход: 10, 2 (000..001010) Изход: 0) + +**Задача 3**: Въвежда се число n. Да се пресметне 2^n. + +**Задача 4**: Въвежда се число n. Да се пресметне числото закодирано в предпоследните 3 бита. diff --git a/Sem. 4/Task1.cpp b/Sem. 04/Task1.cpp index 2fece1e..78ea86d 100644 --- a/Sem. 4/Task1.cpp +++ b/Sem. 04/Task1.cpp @@ -1,14 +1,14 @@ -#include <iostream>
-using namespace std;
-
-int main()
-{
- int n;
- cin >> n;
-
- if (n & 1 == 1)
- cout << "Odd";
- else
- cout << "Even";
-
+#include <iostream> +using namespace std; + +int main() +{ + int n; + cin >> n; + + if (n & 1 == 1) + cout << "Odd"; + else + cout << "Even"; + }
\ No newline at end of file diff --git a/Sem. 4/Task2.cpp b/Sem. 04/Task2.cpp index fca8f47..a45a2e6 100644 --- a/Sem. 4/Task2.cpp +++ b/Sem. 04/Task2.cpp @@ -1,17 +1,17 @@ -#include <iostream>
-using namespace std;
-
-int main()
-{
- int n, k;
- cin >> n >> k;
-
- int temp = 1;
- temp = temp << k;
-
- if ((n & temp) == 0)
- cout << "0";
- else
- cout << "1";
-
+#include <iostream> +using namespace std; + +int main() +{ + int n, k; + cin >> n >> k; + + int temp = 1; + temp = temp << k; + + if ((n & temp) == 0) + cout << "0"; + else + cout << "1"; + }
\ No newline at end of file diff --git a/Sem. 4/Task3.cpp b/Sem. 04/Task3.cpp index 1f21ba4..6e71c31 100644 --- a/Sem. 4/Task3.cpp +++ b/Sem. 04/Task3.cpp @@ -1,10 +1,10 @@ -#include <iostream>
-using namespace std;
-
-int main()
-{
- int n;
- cin >> n;
-
- cout << (1 << n);
+#include <iostream> +using namespace std; + +int main() +{ + int n; + cin >> n; + + cout << (1 << n); }
\ No newline at end of file diff --git a/Sem. 4/Task4.cpp b/Sem. 04/Task4.cpp index 9bb0e6e..b0f5c04 100644 --- a/Sem. 4/Task4.cpp +++ b/Sem. 04/Task4.cpp @@ -1,10 +1,10 @@ -#include <iostream>
-using namespace std;
-
-int main()
-{
- int n;
- cin >> n;
- // 14 = 000...001110 - òàêà ñ "ïîáèòîâî è" ùå âçåìåì ñàìî òåçè 3 áèòà, à îñòàíàëèòå ùå áúäàò 0. Ïîñëå ãè ïðåìåñòâàìå äî íà÷àëîòî (èçïîëçâàéêè >>).
- cout << ((n & 14) >> 1);
+#include <iostream> +using namespace std; + +int main() +{ + int n; + cin >> n; + // 14 = 000...001110 - òàêà ñ "ïîáèòîâî è" ùå âçåìåì ñàìî òåçè 3 áèòà, à îñòàíàëèòå ùå áúäàò 0. Ïîñëå ãè ïðåìåñòâàìå äî íà÷àëîòî (èçïîëçâàéêè >>). + cout << ((n & 14) >> 1); }
\ No newline at end of file diff --git a/Sem. 4/bitwise_examples.cpp b/Sem. 04/bitwise_examples.cpp index b6c01c0..5dd5684 100644 --- a/Sem. 4/bitwise_examples.cpp +++ b/Sem. 04/bitwise_examples.cpp @@ -1,20 +1,20 @@ -#include <iostream>
-using namespace std;
-
-int main()
-{
- int a = 13; // 000...01101
- int b = 20; // 000...10100
-
- int r1 = a & b; // 000...00100(4)
- int r2 = a | b; // 000...11101(29)
- int r3 = a ^ b; // 000...11001(25)
- int r4 = a >> 1;// 000...00110(6)
- int r5 = b << 1;// 000..101000(40)
-
- std::cout << r1 << endl;
- std::cout << r2 << endl;
- std::cout << r3 << endl;
- std::cout << r4 << endl;
- std::cout << r5 << endl;
-}
+#include <iostream> +using namespace std; + +int main() +{ + int a = 13; // 000...01101 + int b = 20; // 000...10100 + + int r1 = a & b; // 000...00100(4) + int r2 = a | b; // 000...11101(29) + int r3 = a ^ b; // 000...11001(25) + int r4 = a >> 1;// 000...00110(6) + int r5 = b << 1;// 000..101000(40) + + std::cout << r1 << endl; + std::cout << r2 << endl; + std::cout << r3 << endl; + std::cout << r4 << endl; + std::cout << r5 << endl; +} diff --git a/Sem. 5/README.md b/Sem. 05/README.md index b65599b..b65599b 100644 --- a/Sem. 5/README.md +++ b/Sem. 05/README.md diff --git a/Sem. 5/Task 1.cpp b/Sem. 05/Task 1.cpp index 20ca708..20ca708 100644 --- a/Sem. 5/Task 1.cpp +++ b/Sem. 05/Task 1.cpp diff --git a/Sem. 5/Task 2.cpp b/Sem. 05/Task 2.cpp index 0f4408d..0f4408d 100644 --- a/Sem. 5/Task 2.cpp +++ b/Sem. 05/Task 2.cpp diff --git a/Sem. 5/Task 3.cpp b/Sem. 05/Task 3.cpp index 6723ee2..6723ee2 100644 --- a/Sem. 5/Task 3.cpp +++ b/Sem. 05/Task 3.cpp diff --git a/Sem. 5/Task 4.cpp b/Sem. 05/Task 4.cpp index 6d57f92..6d57f92 100644 --- a/Sem. 5/Task 4.cpp +++ b/Sem. 05/Task 4.cpp diff --git a/Sem. 5/Task 5.cpp b/Sem. 05/Task 5.cpp index 6f3d0dd..6f3d0dd 100644 --- a/Sem. 5/Task 5.cpp +++ b/Sem. 05/Task 5.cpp diff --git a/Sem. 5/Task 6.cpp b/Sem. 05/Task 6.cpp index 415cae4..415cae4 100644 --- a/Sem. 5/Task 6.cpp +++ b/Sem. 05/Task 6.cpp diff --git a/Sem. 6/README.md b/Sem. 06/README.md index e8c4d0b..e8c4d0b 100644 --- a/Sem. 6/README.md +++ b/Sem. 06/README.md diff --git a/Sem. 6/Task_1(with functions).cpp b/Sem. 06/Task_1(with functions).cpp index db68d0d..db68d0d 100644 --- a/Sem. 6/Task_1(with functions).cpp +++ b/Sem. 06/Task_1(with functions).cpp diff --git a/Sem. 6/Task_1(without functions).cpp b/Sem. 06/Task_1(without functions).cpp index 9e5bcdb..9e5bcdb 100644 --- a/Sem. 6/Task_1(without functions).cpp +++ b/Sem. 06/Task_1(without functions).cpp diff --git a/Sem. 6/Tasks_2,3,4,5,6,7,8,9,10.cpp b/Sem. 06/Tasks_2,3,4,5,6,7,8,9,10.cpp index 1d9666d..1d9666d 100644 --- a/Sem. 6/Tasks_2,3,4,5,6,7,8,9,10.cpp +++ b/Sem. 06/Tasks_2,3,4,5,6,7,8,9,10.cpp diff --git a/Sem. 7/BullsAndColls.cpp b/Sem. 07/BullsAndColls.cpp index 5b5a54e..5b5a54e 100644 --- a/Sem. 7/BullsAndColls.cpp +++ b/Sem. 07/BullsAndColls.cpp diff --git a/Sem. 7/README.md b/Sem. 07/README.md index 2c6303a..2c6303a 100644 --- a/Sem. 7/README.md +++ b/Sem. 07/README.md diff --git a/Sem. 08/README.md b/Sem. 08/README.md new file mode 100644 index 0000000..e8c4d0b --- /dev/null +++ b/Sem. 08/README.md @@ -0,0 +1,35 @@ +**Задача 1:** Въвежда се неотрицателно число n. Да се отпечатат всички двойки прости числа, които са във вида 6k-1 и 6k+1. + +**Задача 2:** Напишете функция, която приема неотрицателно число n и връща числото обърнато + +*Вход: 288, Изход: 822* + +**Задача 3:** Напишете функция, която приема неотрицателно число и връща дали числото е палиндром. + +**Задача 4:** Напишете функция, която приема неотрицателни числа n и k и връща дали k е суфикс на n. + +*Вход: 288, 88, Изход: true* + +**Задача 5:** Напишете функция, която приема неотрицателни числа n и k и връща дали k е префикс на n. + +*Вход: 288, 28, Изход: true* + +**Задача 6:** Напишете функция, която приема неотрицателни числа n и k и връща дали k се съдържа в n. + +*Вход: 2831, 83, Изход: true* + +**Задача 7:** Напишете функция, която приема неотрицателно число n и проверява дали има 4 последователни еднакви цифри. + +*Вход: 28777731, 83, Изход: true* + +**Задача 8:** Напишете функция, която приема неотрицателно число и връща дали цифрите му са сортирани във възходящ ред. + +*Вход: 122239, Изход: true* + +**Задача 9:** Напишете функция, която приема неотрицателно число и връща дали цифрите му са сортирани в низходящ ред. + +*Вход: 99943, Изход: true* + +**Задача 10:** Напишете функция, която приема неотрицателно число и връща дали цифрите му са еднакви. + +*Вход: 111111, Изход: true* diff --git a/Sem. 08/task1.cpp b/Sem. 08/task1.cpp new file mode 100644 index 0000000..f993c7e --- /dev/null +++ b/Sem. 08/task1.cpp @@ -0,0 +1,17 @@ +#include <iostream> +using namespace std; + +const int SIZE = 32; + +int Convert(bool arr[SIZE]) +{ + int result = 0; + for (int i = 31; i >= 0; i--) + result += arr[i] * (1 << 31-i); + return result; +} +int main() +{ + bool arr[SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1 }; + cout << Convert(arr); +}
\ No newline at end of file diff --git a/Sem. 08/task2.cpp b/Sem. 08/task2.cpp new file mode 100644 index 0000000..beb700d --- /dev/null +++ b/Sem. 08/task2.cpp @@ -0,0 +1,42 @@ +#include <iostream> +using namespace std; + +const int SIZE = 30; +int CountOccurrences(int arr[SIZE], int n, int el) +{ + int count = 0; + for (int i = 0; i < n; i++) + { + if (arr[i] == el) + count++; + } + return count; +} + +int GetLonlyNumber(int arr[SIZE], int n) +{ + for (int i = 0; i < n; i++) + { + if (CountOccurrences(arr, n, arr[i]) == 1) + return arr[i]; + } + return -1; + +} + +int GetLonlyNumberBetter(int arr[SIZE], int n) +{ + int res = 0; + for (int i = 0; i < n; i++) + res ^= arr[i]; + return res; +} + +int main() +{ + int arr[SIZE]; + int n; + for (int i = 0; i < n; i++) + cin >> arr[i]; + cout << GetLonlyNumberBetter(arr, n); +}
\ No newline at end of file diff --git a/Sem. 08/task3.cpp b/Sem. 08/task3.cpp new file mode 100644 index 0000000..6d7d209 --- /dev/null +++ b/Sem. 08/task3.cpp @@ -0,0 +1,49 @@ +#include <iostream> +using namespace std; + +const int SIZE = 30; +bool isSubarrayPalindrome(int arr[SIZE], int startIndex, int endIndex) +{ + while (startIndex < endIndex) + { + if (arr[startIndex] != arr[endIndex]) + return false; + startIndex++; + endIndex--; + } + return true; +} +void print(int arr[SIZE]) +{ + for (int i = 0; i < SIZE; i++) + cout << arr[i]; + cout << endl; +} + +int LongestPalindromicSubarray(int arr[SIZE], int n) +{ + int currentSize = n; + + int startIndex = 0; + int endIndex = startIndex + currentSize-1; + while (true) + { + if (isSubarrayPalindrome(arr, startIndex, endIndex)) + return endIndex - startIndex + 1; + startIndex++; + endIndex++; + if (endIndex == n)//last iteration + { + currentSize--; + startIndex = 0; + endIndex = startIndex + currentSize - 1; + } + } +} +int main() +{ + + int arr[SIZE] = {1,4,3,2,3}; + cout << LongestPalindromicSubarray(arr, 5); + +} |
