diff options
new
23 files changed, 0 insertions, 687 deletions
diff --git a/Sem. 03/Contains5.cpp b/Sem. 03/Contains5.cpp deleted file mode 100644 index 78d13f0..0000000 --- a/Sem. 03/Contains5.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - int n; - cin >> n; - - bool foundFive = false; - while (n != 0) - { - int lastDigit = n % 10; - if (lastDigit == 5) - { - foundFive = true; - break; - } - n /= 10; - } - - if (foundFive) - { - cout << "yes"; - } - else - { - cout << "no"; - } - - -}
\ No newline at end of file diff --git a/Sem. 03/GCD_solution1.cpp b/Sem. 03/GCD_solution1.cpp deleted file mode 100644 index 58ea35b..0000000 --- a/Sem. 03/GCD_solution1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - int n, k; - - cin >> n >> k; - - if (n < k) //swap - { - int temp = n; - n = k; - k = temp; - } - - int devider = 1; - int result; - while (devider <= k) - { - if (n % devider == 0 && k % devider == 0) - { - result = devider; - } - devider++; - } - - cout << result; - - -}
\ No newline at end of file diff --git a/Sem. 03/GCD_solution2.cpp b/Sem. 03/GCD_solution2.cpp deleted file mode 100644 index ba06c89..0000000 --- a/Sem. 03/GCD_solution2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - int n, k; - - cin >> n >> k; - - if (n < k) //swap - { - int temp = n; - n = k; - k = temp; - - } - int devider = k; - bool foundSolution = false; - - - while (!foundSolution) - { - if (n % devider == 0 && k % devider == 0) - foundSolution = true; - else - devider--; - - - } - cout << devider; - - - -}
\ No newline at end of file diff --git a/Sem. 03/GCD_solution3_Eucid.cpp b/Sem. 03/GCD_solution3_Eucid.cpp deleted file mode 100644 index f190a90..0000000 --- a/Sem. 03/GCD_solution3_Eucid.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - int n, k; - - cin >> n >> k; - - if (n < k) //swap - { - int temp = n; - n = k; - k = temp; - } - - while (k != 0) - { - int div = n % k; - n = k; - k = div; - } - cout << n << endl; -}
\ No newline at end of file diff --git a/Sem. 03/PrintEvenNumbers.cpp b/Sem. 03/PrintEvenNumbers.cpp deleted file mode 100644 index e9a2231..0000000 --- a/Sem. 03/PrintEvenNumbers.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - int n; - cin >> n; - - int j = 0; - while (j <= n) - { - cout << j << endl; - j += 2; - } - - //Here the variable j is reachable! - - - for (int i = 0; i <=n; i++) - { - cout << i << endl; - } - // Here the variable i is NOT reachable. - - -}
\ No newline at end of file diff --git a/Sem. 03/README.md b/Sem. 03/README.md deleted file mode 100644 index 5d510c5..0000000 --- a/Sem. 03/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# Цикли -### Цикъл for - -```c++ - -for( <Инициализация(i)>; <Булево условие>; <Актуализация(i)> ) -{ - <Тяло на цикъла(i)> -} - - ``` - Изпълнението работи така: -1. Изпълнява се инициализацията -2. Проверява се булевото условие; - - 2.1 ако има стойност **лъжа**, цикълът приключва - - 2.2 ако има стойност **истина**, се изпълнава 3. - -3. Изпълнява се тялото на цикъла. -4. Изпълнява се инкрементацията. Отиваме на точка 2. -### Цикъл while -```c++ -while ( <Булево условие> ) -{ - <Тяло на цикъла> -} - ``` -Изпълнението работи така: -1. Проверява се булевото условие; - - 1.1 ако има стойност **лъжа**, цикълът приключва - - 1.2 ако има стойност **истина**, се изпълнава 2. - -2. Изпълнява се тялото на цикъла. Отиваме на 1. - -### Цикъл do- while -```c++ -do -{ - <Тяло на цикъла> - -}while ( <Булево условие> ); - ``` - Изпълнението работи така: -1. Изпълнява се тялото на цикъла. -2. Проверява се булевото условие - - 2.1 ако има стойност **лъжа**, цикълът приключва - - 2.2 ако има стойност **истина**, отиваме на точка 1. - -# Конвертиране на цикли. - - - -### От for към while. -```c++ -// for loop -for(int i = 0; i < 10; i++) -{ - <Тяло на цикъла> -} - -// for loop converted to while loop -int i = 0; //Инициализация -while(i < 10) -{ - <Тяло на цикъла> - i++; // Актуализация -} - ``` -### От while към for. - -```c++ - -// while loop -while(*str != '\0') -{ - <Тяло на цикъла> - ++str; -} - - -// while loop converted to for loop -for(; *str != '\0'; ++str) -{ - <Тяло на цикъла> -} - ``` - ### От do-while към while. -```c++ -// do-while loop -do -{ - <Тяло на цикъла> - -} while ( <Условие> ); - - -// do-while loop converted to while loop -<Тяло на цикъла> -while( <Условие> ) -{ - <Тяло на цикъла> -} - ``` -Забележка! Предложените начини за преобразуване между цикли са с демонстрационна цел! Спрямо конкретната цитуация може да се постигне такова преобразуване и по много по-прост начин. diff --git a/Sem. 03/SimpleDevidersCount_PrimalityCheck.cpp b/Sem. 03/SimpleDevidersCount_PrimalityCheck.cpp deleted file mode 100644 index db39c9c..0000000 --- a/Sem. 03/SimpleDevidersCount_PrimalityCheck.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - unsigned int n; //allways positive int - cin >> n; - - int divCount = 0; - - for (int i = 1; i <= n; i++) - { - if (n%i == 0) - divCount++; - } - //Can we reduce the number of steps? - - if (divCount == 2) - { - cout << "Prime" << endl; - } - else - { - cout << "Not a prime" << endl; - } - - - -} diff --git a/Sem. 03/SumOfDigits.cpp b/Sem. 03/SumOfDigits.cpp deleted file mode 100644 index 6777a42..0000000 --- a/Sem. 03/SumOfDigits.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include <iostream> - -using namespace std; - -int main() -{ - int n; - cin >> n; - - int digitSum = 0; - - while (n != 0) - { - int lastDigit = n % 10; //extracts last digit - digitSum += lastDigit; //adds it to the sum - n /= 10; //removes last digit - } - - cout << digitSum; - - -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/01. Between100and200.cpp b/Sem. 03/Tasks and Solutions/01. Between100and200.cpp deleted file mode 100644 index 0817bcc..0000000 --- a/Sem. 03/Tasks and Solutions/01. Between100and200.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - unsigned int n; - cin >> n; - - if (n < 100) - cout << "Less than 100" << endl; - else if (n <= 200) - cout << "Between 100 and 200" << endl; - else - cout << "More than 200" << endl; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/02. Speed check.cpp b/Sem. 03/Tasks and Solutions/02. Speed check.cpp deleted file mode 100644 index 4660382..0000000 --- a/Sem. 03/Tasks and Solutions/02. Speed check.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - double speed; - cin >> speed; - - if (speed <= 10) - cout << "Slow" << endl; - else if (speed < 50) - cout << "Average" << endl; - else if (speed < 150) - cout << "Fast" << endl; - else if (speed < 1000) - cout << "Ultra fast" << endl; - else - cout << "Extremely fast" << endl; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/03. Figures.cpp b/Sem. 03/Tasks and Solutions/03. Figures.cpp deleted file mode 100644 index 170c403..0000000 --- a/Sem. 03/Tasks and Solutions/03. Figures.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <iostream> -using namespace std; - -const double PI = 3.14; -int main() -{ - char figure; - cin >> figure; - - if (figure == 's') - { - double side; - cin >> side; - cout << side * side << endl; - } - else if (figure == 'r') - { - double sideA, sideB; - cin >> sideA >> sideB; - cout << sideA * sideB << endl; - } - else if (figure == 'c') - { - double R; - cin >> R; - cout << PI * R * R << endl; - } -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/04. Time + 15.cpp b/Sem. 03/Tasks and Solutions/04. Time + 15.cpp deleted file mode 100644 index aee3118..0000000 --- a/Sem. 03/Tasks and Solutions/04. Time + 15.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include <iostream> -using namespace std; - -const double PI = 3.14; -int main() -{ - int hours, mins; - cin >> hours >> mins; - - (mins += 15) %= 60; - - if (mins < 15) - (hours+=1)%=24; - - if (hours <= 9) - cout << 0; - cout << hours << ":"; - if (mins <= 9) - cout << 0; - cout << mins << endl; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp b/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp deleted file mode 100644 index 68940e0..0000000 --- a/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int a, b, c, d, e; - cin >> a >> b >> c >> d >> e; - - if ((a <= b && b >= c && c <= d && d >= e) - || (a >= b && b <= c && c >= d && d <= e)) - { - cout << "Yes"; - } - else - cout << "No"; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/06. DivBy3.cpp b/Sem. 03/Tasks and Solutions/06. DivBy3.cpp deleted file mode 100644 index 044aee9..0000000 --- a/Sem. 03/Tasks and Solutions/06. DivBy3.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int n; - cin >> n; - - for (int i = 3; i <= n; i+=3) - cout << i << endl; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp deleted file mode 100644 index 4ae1131..0000000 --- a/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int n, searchedDigit; - cin >> n >> searchedDigit; - - bool found = false; - while (n != 0) - { - int lastDigit = n % 10; - if (searchedDigit == lastDigit) - { - found = true; - break; - } - n /= 10; - } -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp b/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp deleted file mode 100644 index 0fa5946..0000000 --- a/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - bool found0, found1, found2, found3, found4, found5, found6, found7, found8, found9; - found0 = found1 = found2 = found3 = found4 = found5 = found6 = found7 = found8 = found9 = false; - - int n; - cin >> n; - - bool foundDuplicate = false; - while (!foundDuplicate && n != 0) - { - int lastDigit = n % 10; - switch (lastDigit) - { - case 0: - if (found0) - { - foundDuplicate = true; - - } - found0 = true; - break; - case 1: - if (found1) - { - foundDuplicate = true; - } - found1 = true; - break; - case 2: - if (found2) - { - foundDuplicate = true; - } - found2 = true; - break; - case 3: - if (found3) - { - foundDuplicate = true; - } - found3 = true; - break; - case 4: - if (found4) - { - foundDuplicate = true; - } - found4 = true; - break; - case 5: - if (found5) - { - foundDuplicate = true; - } - found5 = true; - break; - case 6: - if (found6) - { - foundDuplicate = true; - } - found6 = true; - break; - case 7: - if (found7) - { - foundDuplicate = true; - } - found7 = true; - break; - case 8: - if (found8) - { - foundDuplicate = true; - } - found8 = true; - case 9: - if (found9) - { - foundDuplicate = true; - } - found9 = true; - break; - } - n /= 10; - } - - cout << foundDuplicate; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp b/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp deleted file mode 100644 index aea318a..0000000 --- a/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int n, k; - cin >> k >> n; - - int sum = 0; - for (int i = k; i <= n; i++) - sum += i; - - cout << sum << endl; - - //or use the formula - - cout << (n*(n + 1)) / 2 - ((k - 1)*k) / 2 << endl; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/10. Pyramid.cpp b/Sem. 03/Tasks and Solutions/10. Pyramid.cpp deleted file mode 100644 index 5d9e2a9..0000000 --- a/Sem. 03/Tasks and Solutions/10. Pyramid.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int n; - cin >> n; - for (int i = 1; i <= n; i++) - { - for (int j = 1; j <= i; j++) - cout << "$"; - cout << endl; - } -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/11. Clock.cpp b/Sem. 03/Tasks and Solutions/11. Clock.cpp deleted file mode 100644 index 6386ca0..0000000 --- a/Sem. 03/Tasks and Solutions/11. Clock.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - for (int hour = 0; hour <= 23; hour++) - { - for (int min = 0; min <= 59; min++) - { - if (hour < 10) - cout << 0; - cout << hour << ":"; - if (min < 10) - cout << 0; - cout << min << endl; - } - } -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp b/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp deleted file mode 100644 index 1b996e1..0000000 --- a/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int h, m; - cin >> h >> m; - - for (int min = m + 1; min <= 59; min++) - { - if (h < 10) - cout << 0; - cout << h << ":"; - if (min < 10) - cout << 0; - cout << min << endl; - } - - for (int hour = h+1; hour <= 23; hour++) - { - for (int min = 0; min <= 59; min++) - { - if (hour < 10) - cout << 0; - cout << hour << ":"; - if (min < 10) - cout << 0; - cout << min << endl; - } - } -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp b/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp deleted file mode 100644 index af39745..0000000 --- a/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int hStart, mStart, hEnd, mEnd; - cin >> hStart >> mStart >> hEnd >> mEnd; - - for (int min = mStart + 1; min <= 59; min++) - { - if (hStart < 10) - cout << 0; - cout << hStart << ":"; - if (min < 10) - cout << 0; - cout << min << endl; - } - - for (int hour = hStart+1; hour <= hEnd-1; hour++) - { - for (int min = 0; min <= 59; min++) - { - if (hour < 10) - cout << 0; - cout << hour << ":"; - if (min < 10) - cout << 0; - cout << min << endl; - } - } - - for (int min = 0; min < mEnd; min++) - { - if (hEnd < 10) - cout << 0; - cout << hEnd << ":"; - if (min < 10) - cout << 0; - cout << min << endl; - } -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/14. Frame.cpp b/Sem. 03/Tasks and Solutions/14. Frame.cpp deleted file mode 100644 index 92de3ca..0000000 --- a/Sem. 03/Tasks and Solutions/14. Frame.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include <iostream> -using namespace std; - -int main() -{ - int n; - cin >> n; - - //Ãîðíà ðàìêà - cout << '+'; - for (int i = 0; i < n - 2; i++) - cout << '-'; - cout << '+' << endl; - - - //Ñðåäà - for (int j = 0; j < n - 2; j++) - { - cout << '|'; - for (int i = 0; i < n - 2; i++) - cout << '-'; - cout << '|' << endl; - } - - //Äîëíà ðàìêà - cout << '+'; - for (int i = 0; i < n - 2; i++) - cout << '-'; - cout << '+' << endl; -}
\ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/tasks.pdf b/Sem. 03/Tasks and Solutions/tasks.pdf Binary files differdeleted file mode 100644 index 6c2ad50..0000000 --- a/Sem. 03/Tasks and Solutions/tasks.pdf +++ /dev/null |
