From 00f15aa8d69a53c3ffa55661283aa06a6d6bd30f Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Thu, 28 Oct 2021 17:33:12 +0300 Subject: Update sem.03 --- pract_SI/Pract. 03-04/Solutions/task1.cpp | 19 ----- pract_SI/Pract. 03-04/Solutions/task2.cpp | 17 ---- pract_SI/Pract. 03-04/Solutions/task3.cpp | 22 ----- pract_SI/Pract. 03-04/Solutions/task4.cpp | 21 ----- pract_SI/Pract. 03-04/Solutions/task5.cpp | 41 ---------- pract_SI/Pract. 03-04/Solutions/task6.cpp | 18 ---- pract_SI/Pract. 03-04/Solutions/task7.cpp | 30 ------- pract_SI/Pract. 03-04/Solutions/task8.cpp | 41 ---------- pract_SI/Pract. 03-04/Solutions/task9.cpp | 59 -------------- pract_SI/Pract. 03-04/Startup_tasks.txt | 7 -- pract_SI/Pract. 03-04/Tasks3.txt | 131 ------------------------------ pract_SI/Pract. 03/Solutions/task1.cpp | 19 +++++ pract_SI/Pract. 03/Solutions/task2.cpp | 17 ++++ pract_SI/Pract. 03/Solutions/task3.cpp | 22 +++++ pract_SI/Pract. 03/Solutions/task4.cpp | 21 +++++ pract_SI/Pract. 03/Solutions/task5.cpp | 41 ++++++++++ pract_SI/Pract. 03/Solutions/task6.cpp | 18 ++++ pract_SI/Pract. 03/Solutions/task7.cpp | 30 +++++++ pract_SI/Pract. 03/Solutions/task8.cpp | 41 ++++++++++ pract_SI/Pract. 03/Solutions/task9.cpp | 59 ++++++++++++++ pract_SI/Pract. 03/Startup_tasks.txt | 7 ++ pract_SI/Pract. 03/Tasks3.txt | 131 ++++++++++++++++++++++++++++++ 22 files changed, 406 insertions(+), 406 deletions(-) delete mode 100644 pract_SI/Pract. 03-04/Solutions/task1.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task2.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task3.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task4.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task5.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task6.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task7.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task8.cpp delete mode 100644 pract_SI/Pract. 03-04/Solutions/task9.cpp delete mode 100644 pract_SI/Pract. 03-04/Startup_tasks.txt delete mode 100644 pract_SI/Pract. 03-04/Tasks3.txt create mode 100644 pract_SI/Pract. 03/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task2.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task3.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task6.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task7.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task8.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task9.cpp create mode 100644 pract_SI/Pract. 03/Startup_tasks.txt create mode 100644 pract_SI/Pract. 03/Tasks3.txt (limited to 'pract_SI') diff --git a/pract_SI/Pract. 03-04/Solutions/task1.cpp b/pract_SI/Pract. 03-04/Solutions/task1.cpp deleted file mode 100644 index ae955a8..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "pch.h" -#include - -using namespace std; - -int main() -{ - unsigned long long number; - cin >> number; - - for (int i = 1; i <= number; i++) - { - for (int j = 1; j <= i; j++) - cout << j; - cout << endl; - } - - return 0; -} diff --git a/pract_SI/Pract. 03-04/Solutions/task2.cpp b/pract_SI/Pract. 03-04/Solutions/task2.cpp deleted file mode 100644 index b3e970d..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -using namespace std; - -int main() -{ - unsigned long long number; - cin >> number; - - for (unsigned long long x = 1, y = number; x < number; x++) - { - cout << "x = " << x << " " - << "y = " << --y << endl; - } - - return 0; -} diff --git a/pract_SI/Pract. 03-04/Solutions/task3.cpp b/pract_SI/Pract. 03-04/Solutions/task3.cpp deleted file mode 100644 index a6a6362..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task3.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned long long oldNumber, newNumber; - - cout << "Enter a positive number: "; - cin >> oldNumber; - - oldNumber *= oldNumber; - newNumber = 0; - - while (oldNumber != 0) - { - newNumber = newNumber * 10 + oldNumber % 10; - oldNumber /= 10; - } - - cout << newNumber << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Solutions/task4.cpp b/pract_SI/Pract. 03-04/Solutions/task4.cpp deleted file mode 100644 index 622b8a1..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task4.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned int m, n; - cout << "Number of rows: "; - cin >> m; - cout << "Number of columns: "; - cin >> n; - - for (unsigned int i = 1; i <= m * n; i++) - { - cout << i << " "; - if (i % n == 0) - { - cout << endl; - } - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Solutions/task5.cpp b/pract_SI/Pract. 03-04/Solutions/task5.cpp deleted file mode 100644 index d6ac57c..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task5.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned short number, guess; - unsigned int counter = 0; - - cout << "Enter a number between 0 and 100: "; - cin >> number; - if (number < 0 || number > 100) - { - cout << "Invalid input!\n"; - return 1; - } - - do - { - ++counter; - - cout << "Guess " << counter << ": "; - cin >> guess; - if (guess < 0 || guess > 100) - { - cout << "Invalid input!\n"; - return 2; - } - - if (guess < number) - { - cout << "The number you are looking for is greater than your guess!\n"; - } - else if (guess > number) - { - cout << "The number you are looking for is less than your guess!\n"; - } - } while (guess != number); - - cout << "You found the number in " << counter << " attempt(s)!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Solutions/task6.cpp b/pract_SI/Pract. 03-04/Solutions/task6.cpp deleted file mode 100644 index 8d0beac..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task6.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned int number = 0, input = 1; - - while(input != 0) - { - cout << "Enter a positive number: "; - cin >> input; - - number ^= input; - } - - cout << "The single number is " << number << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Solutions/task7.cpp b/pract_SI/Pract. 03-04/Solutions/task7.cpp deleted file mode 100644 index aa9194b..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task7.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#define LIMIT 5 -#define SEPARATOR " " - -using namespace std; - -//const short LIMIT = 5; -//const char SEPARATOR = ' '; - - -int main() -{ - unsigned long long N; - cin >> N; - - if (N < LIMIT) - return -1; - - for (int c = 1; c <= N; c++) { - for (int b = 1; b < c; b++) { - for (int a = 1; a < b; a++) { - if ((a * a) + (b * b) == (c * c)) { - cout << a << SEPARATOR << b << SEPARATOR << c << endl; - } - } - } - } - - return 0; -} diff --git a/pract_SI/Pract. 03-04/Solutions/task8.cpp b/pract_SI/Pract. 03-04/Solutions/task8.cpp deleted file mode 100644 index 3f32ebf..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task8.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include - -using namespace std; - -const short LOWERLIMIT = 2; -const short UPPERLIMIT = 9; -const char SEPARATOR = ' '; - -int main() -{ - short N; - char S; - cin >> N >> S; - - if (N < LOWERLIMIT || N > UPPERLIMIT) - return -1; //end program - - for (int i = 1; i <= N; i++) - { - for (int j = N - i; j > 0; j--) - cout << SEPARATOR; - - for (int k = 1; k < 2 * i; k++) - cout << S; - - cout << endl; - } - - for (int i = 1; i < N; i++) - { - for (int j = 1; j <= i; j++) - cout << SEPARATOR; - - for (int k = 1; k < 2 * (N - i); k++) - cout << S; - - cout << endl; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Solutions/task9.cpp b/pract_SI/Pract. 03-04/Solutions/task9.cpp deleted file mode 100644 index 9f1f054..0000000 --- a/pract_SI/Pract. 03-04/Solutions/task9.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include - -int main() { - - // по-нататък ще учим как се вкарват сложни данни, затова сега ще ги hardcode-нем в main-а - - int hoursOnesStart = 2, minutesTensStart = 5, secondsOnesStart = 6; - int hoursOnesFinal = 1, minutesTensFinal = 0, secondsOnesFinal = 2; - int hoursDelta = 10, minutesDelta = 19, secondsDelta = 26; - - for (size_t hoursTensStart = 0; hoursTensStart <= 1; ++hoursTensStart) - { - for (size_t minutesOnesStart = 0; minutesOnesStart <= 9; ++minutesOnesStart) - { - for (size_t secondsTensStart = 0; secondsTensStart <= 5; secondsTensStart++) - { - int hoursTemp = hoursTensStart * 10 + hoursOnesStart; - int minutesTemp = minutesTensStart * 10 + minutesOnesStart; - int secondsTemp = secondsTensStart * 10 + secondsOnesStart; - - secondsTemp += secondsDelta; - if (secondsTemp >= 60) { - minutesTemp += secondsTemp / 60; - secondsTemp %= 60; - } - - minutesTemp += minutesDelta; - if (minutesTemp >= 60) { - hoursTemp += minutesTemp / 60; - minutesTemp %= 60; - } - - hoursTemp += hoursDelta; - if (hoursTemp > 12) { - hoursTemp %= 12; - } - - bool hoursOnesMatch = hoursTemp % 10 == hoursOnesFinal, - minutesTensMatch = minutesTemp / 10 == minutesTensFinal, - secondsOnesMatch = secondsTemp % 10 == secondsOnesFinal; - - if (hoursOnesMatch && minutesTensMatch && secondsOnesMatch) { - int hoursTensFinal = hoursTemp / 10, - minutesOnesFinal = minutesTemp % 10, - secondsTensFinal = secondsTemp / 10; - - std::cout << hoursTensStart << hoursOnesStart << ':' - << minutesTensStart << minutesOnesStart << ':' - << secondsTensStart << secondsOnesStart << ' ' - << hoursTensFinal << hoursOnesFinal << ':' - << minutesTensFinal << minutesOnesFinal << ':' - << secondsTensFinal << secondsOnesFinal << '\n'; - } - } - } - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Startup_tasks.txt b/pract_SI/Pract. 03-04/Startup_tasks.txt deleted file mode 100644 index 8ee6d58..0000000 --- a/pract_SI/Pract. 03-04/Startup_tasks.txt +++ /dev/null @@ -1,7 +0,0 @@ -1.Напишете програма , която приема като вход N лева.Да се отпечата как бихме разпределили сумата на банкноти, -така че да имаме минимален брой банкноти. (Да не се използват условни оператори и цикли) -Пояснение: Нека да приемем, че имаме банкноти с 1лв и 2лв. - -2.Напишете програма, която приема като вход цяло положително число V, което ще отговаря на скорост. -Програмата да отпечатва колко е глобата от КАТ, а ако няма глоба следното съобщение "No speedticket". -(https://stamatovandpartners.com/elektronen-fish-za-previshena-skorost/) \ No newline at end of file diff --git a/pract_SI/Pract. 03-04/Tasks3.txt b/pract_SI/Pract. 03-04/Tasks3.txt deleted file mode 100644 index 64c5c4c..0000000 --- a/pract_SI/Pract. 03-04/Tasks3.txt +++ /dev/null @@ -1,131 +0,0 @@ -#Никола Светославов - task3 - -## Задачи - -1.Да се напише програма, която приема естествено число n и изписва стълба от 1 до n - -Пример -Вход: -5 -Изход: -1 -12 -123 -1234 -12345 - -2.Да се състави програма, която по въведено естествено число n да изведе всички естествени решения на уравнението x + y = n. - -Пример -Вход: -4 -Изход: -x = 1 y = 3 -x = 2 y = 2 -x = 3 y = 1 - - -3.Напишете програма, която по въведено цяло положително число, извежда квадратът на това число, но в обратен ред, като водещите нули се игнорират. - -Пример -Вход: -10 -Изход: -1 - -Вход: -25 -Изход: -526 - -4.Напишете програма, която приема от потребителя две цели положителни числа - *m* и *n*. - Програмата да отпечата числатаот 1 до m*n, като на всеки ред има по *n* числа (тоест ще отпечатате *m* реда). - Печатайте числата по редове: - -Пример -Вход: -2 3 -Изход: -1 2 3 -4 5 6 - -5.Напишете проста игра, в която първо се въвежда цяло число в интервала [0;100] и в последствие се въвеждат цели числа - (предположения), като за всяко се казва дали е по - малко или по - голямо от първоначално ваведеното. - Tова продължава до въвеждане на число, равно на първоначалното. Програмата да отпечата и броят направени предположения. - -6.Напишете програма, която иска от потребителя поредица от цели числа по - големи от 0. - Въвеждането приключва с въвеждане на 0. Гарантирано е, че всяко от числата е въведено **точно два пъти** освен едно, - което е въведено **точно веднъж**. Програмата да изведе кое е това число. - -7.Да се състави програма, която по въведено естествено число N намира и отпечатва всички тройки естествени числа a, b и c, - не по-големи от N, които могат да бъдат страни на правоъгълен триъгълник. - -Пример -Вход: -11 -Изход -3 4 5 -6 8 10 - -8.Напишете програма, която иска от потребителя вход цифра N[2;9] и символ S.Програмата да извежда фигура съставена от символа във вид на ромб, както е показано на примерите. - -Пример -Вход: -5 * -Изход - * - *** - ***** - ******* -********* - ******* - ***** - *** - * - -*Бонус* -Задача ЕЛЕКТРОНЕН ЧАСОВНИК -В големия нов МОЛ в града на програмистите се повредили част от цифрите на електронния часовник. -Повредени били първата цифра от числото, което показва часовете, втората цифра на числото, което показва минутите и първата цифра на числото, което показва секундите. -Вместо тях на екрана се появявал знака *. -Когато Коко и приятелите му ходели на кино, те не успявали да преценят точно колко е часа. -Все пак, момчетата си създали система за изчисление, която приблизително точно им показвало времето. -Те успявали да предвидят колко е показвал часовника в началото и края на филма, в случай че знаят точно колко време е минало. -Срещу името на всеки филм на входа на киното е дадено неговото времетраене в часове, минути и секунди. -Пресмятанията доста затрудняват момчетата и затова на тях ще им е по-удобно това да се прави с компютърна програма. -Те не разбират много от програмиране и затова вие трябва да напишете програма clock, която помага на Коко и приятелите му. - -Вход: -На първия ред на стандартния вход е записана последователност от цифри и знака *, която показва какво се вижда на екрана на часовника в началото на филма. -На втория ред е записана подобна последователност за показанието на часовника в края на филма. -На третия ред се въвежда продължителността на филма в часове, минути и секунди. -Часовникът е настроен така, че показва времето по 12-часова скала, а не по 24-часова. - -Изход: -На стандартния изход изведете всички възможни показания на часовника за началото и края на филма. -Всяка двойка с начален и краен час се извежда на един ред, като първо се извежда началното показание във формат hh:mm:ss, и след един интервал крайното показание в същия формат. -Ако такива показания на часовника не са възможни, да се изведе “Impossible”. - -Ограничения: -Продължителността на филма е не по-голяма 12 часа. - -Примери: - -Вход: -*25**6 -*10**2 -10 19 26 -Изход: -02:50:06 01:09:32 -02:50:16 01:09:42 -02:50:26 01:09:52 -12:50:06 11:09:32 -12:50:16 11:09:42 -12:50:26 11:09:52 - -Вход: -*95**6 -*21**2 -4 12 6 -Изход: -Impossible diff --git a/pract_SI/Pract. 03/Solutions/task1.cpp b/pract_SI/Pract. 03/Solutions/task1.cpp new file mode 100644 index 0000000..ae955a8 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task1.cpp @@ -0,0 +1,19 @@ +#include "pch.h" +#include + +using namespace std; + +int main() +{ + unsigned long long number; + cin >> number; + + for (int i = 1; i <= number; i++) + { + for (int j = 1; j <= i; j++) + cout << j; + cout << endl; + } + + return 0; +} diff --git a/pract_SI/Pract. 03/Solutions/task2.cpp b/pract_SI/Pract. 03/Solutions/task2.cpp new file mode 100644 index 0000000..b3e970d --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task2.cpp @@ -0,0 +1,17 @@ +#include + +using namespace std; + +int main() +{ + unsigned long long number; + cin >> number; + + for (unsigned long long x = 1, y = number; x < number; x++) + { + cout << "x = " << x << " " + << "y = " << --y << endl; + } + + return 0; +} diff --git a/pract_SI/Pract. 03/Solutions/task3.cpp b/pract_SI/Pract. 03/Solutions/task3.cpp new file mode 100644 index 0000000..a6a6362 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task3.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; +int main() +{ + unsigned long long oldNumber, newNumber; + + cout << "Enter a positive number: "; + cin >> oldNumber; + + oldNumber *= oldNumber; + newNumber = 0; + + while (oldNumber != 0) + { + newNumber = newNumber * 10 + oldNumber % 10; + oldNumber /= 10; + } + + cout << newNumber << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task4.cpp b/pract_SI/Pract. 03/Solutions/task4.cpp new file mode 100644 index 0000000..622b8a1 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task4.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; +int main() +{ + unsigned int m, n; + cout << "Number of rows: "; + cin >> m; + cout << "Number of columns: "; + cin >> n; + + for (unsigned int i = 1; i <= m * n; i++) + { + cout << i << " "; + if (i % n == 0) + { + cout << endl; + } + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task5.cpp b/pract_SI/Pract. 03/Solutions/task5.cpp new file mode 100644 index 0000000..d6ac57c --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task5.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +int main() +{ + unsigned short number, guess; + unsigned int counter = 0; + + cout << "Enter a number between 0 and 100: "; + cin >> number; + if (number < 0 || number > 100) + { + cout << "Invalid input!\n"; + return 1; + } + + do + { + ++counter; + + cout << "Guess " << counter << ": "; + cin >> guess; + if (guess < 0 || guess > 100) + { + cout << "Invalid input!\n"; + return 2; + } + + if (guess < number) + { + cout << "The number you are looking for is greater than your guess!\n"; + } + else if (guess > number) + { + cout << "The number you are looking for is less than your guess!\n"; + } + } while (guess != number); + + cout << "You found the number in " << counter << " attempt(s)!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task6.cpp b/pract_SI/Pract. 03/Solutions/task6.cpp new file mode 100644 index 0000000..8d0beac --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task6.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; +int main() +{ + unsigned int number = 0, input = 1; + + while(input != 0) + { + cout << "Enter a positive number: "; + cin >> input; + + number ^= input; + } + + cout << "The single number is " << number << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task7.cpp b/pract_SI/Pract. 03/Solutions/task7.cpp new file mode 100644 index 0000000..aa9194b --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task7.cpp @@ -0,0 +1,30 @@ +#include +#define LIMIT 5 +#define SEPARATOR " " + +using namespace std; + +//const short LIMIT = 5; +//const char SEPARATOR = ' '; + + +int main() +{ + unsigned long long N; + cin >> N; + + if (N < LIMIT) + return -1; + + for (int c = 1; c <= N; c++) { + for (int b = 1; b < c; b++) { + for (int a = 1; a < b; a++) { + if ((a * a) + (b * b) == (c * c)) { + cout << a << SEPARATOR << b << SEPARATOR << c << endl; + } + } + } + } + + return 0; +} diff --git a/pract_SI/Pract. 03/Solutions/task8.cpp b/pract_SI/Pract. 03/Solutions/task8.cpp new file mode 100644 index 0000000..3f32ebf --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task8.cpp @@ -0,0 +1,41 @@ +#include + +using namespace std; + +const short LOWERLIMIT = 2; +const short UPPERLIMIT = 9; +const char SEPARATOR = ' '; + +int main() +{ + short N; + char S; + cin >> N >> S; + + if (N < LOWERLIMIT || N > UPPERLIMIT) + return -1; //end program + + for (int i = 1; i <= N; i++) + { + for (int j = N - i; j > 0; j--) + cout << SEPARATOR; + + for (int k = 1; k < 2 * i; k++) + cout << S; + + cout << endl; + } + + for (int i = 1; i < N; i++) + { + for (int j = 1; j <= i; j++) + cout << SEPARATOR; + + for (int k = 1; k < 2 * (N - i); k++) + cout << S; + + cout << endl; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task9.cpp b/pract_SI/Pract. 03/Solutions/task9.cpp new file mode 100644 index 0000000..9f1f054 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task9.cpp @@ -0,0 +1,59 @@ +#include + +int main() { + + // по-нататък ще учим как се вкарват сложни данни, затова сега ще ги hardcode-нем в main-а + + int hoursOnesStart = 2, minutesTensStart = 5, secondsOnesStart = 6; + int hoursOnesFinal = 1, minutesTensFinal = 0, secondsOnesFinal = 2; + int hoursDelta = 10, minutesDelta = 19, secondsDelta = 26; + + for (size_t hoursTensStart = 0; hoursTensStart <= 1; ++hoursTensStart) + { + for (size_t minutesOnesStart = 0; minutesOnesStart <= 9; ++minutesOnesStart) + { + for (size_t secondsTensStart = 0; secondsTensStart <= 5; secondsTensStart++) + { + int hoursTemp = hoursTensStart * 10 + hoursOnesStart; + int minutesTemp = minutesTensStart * 10 + minutesOnesStart; + int secondsTemp = secondsTensStart * 10 + secondsOnesStart; + + secondsTemp += secondsDelta; + if (secondsTemp >= 60) { + minutesTemp += secondsTemp / 60; + secondsTemp %= 60; + } + + minutesTemp += minutesDelta; + if (minutesTemp >= 60) { + hoursTemp += minutesTemp / 60; + minutesTemp %= 60; + } + + hoursTemp += hoursDelta; + if (hoursTemp > 12) { + hoursTemp %= 12; + } + + bool hoursOnesMatch = hoursTemp % 10 == hoursOnesFinal, + minutesTensMatch = minutesTemp / 10 == minutesTensFinal, + secondsOnesMatch = secondsTemp % 10 == secondsOnesFinal; + + if (hoursOnesMatch && minutesTensMatch && secondsOnesMatch) { + int hoursTensFinal = hoursTemp / 10, + minutesOnesFinal = minutesTemp % 10, + secondsTensFinal = secondsTemp / 10; + + std::cout << hoursTensStart << hoursOnesStart << ':' + << minutesTensStart << minutesOnesStart << ':' + << secondsTensStart << secondsOnesStart << ' ' + << hoursTensFinal << hoursOnesFinal << ':' + << minutesTensFinal << minutesOnesFinal << ':' + << secondsTensFinal << secondsOnesFinal << '\n'; + } + } + } + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Startup_tasks.txt b/pract_SI/Pract. 03/Startup_tasks.txt new file mode 100644 index 0000000..8ee6d58 --- /dev/null +++ b/pract_SI/Pract. 03/Startup_tasks.txt @@ -0,0 +1,7 @@ +1.Напишете програма , която приема като вход N лева.Да се отпечата как бихме разпределили сумата на банкноти, +така че да имаме минимален брой банкноти. (Да не се използват условни оператори и цикли) +Пояснение: Нека да приемем, че имаме банкноти с 1лв и 2лв. + +2.Напишете програма, която приема като вход цяло положително число V, което ще отговаря на скорост. +Програмата да отпечатва колко е глобата от КАТ, а ако няма глоба следното съобщение "No speedticket". +(https://stamatovandpartners.com/elektronen-fish-za-previshena-skorost/) \ No newline at end of file diff --git a/pract_SI/Pract. 03/Tasks3.txt b/pract_SI/Pract. 03/Tasks3.txt new file mode 100644 index 0000000..64c5c4c --- /dev/null +++ b/pract_SI/Pract. 03/Tasks3.txt @@ -0,0 +1,131 @@ +#Никола Светославов - task3 + +## Задачи + +1.Да се напише програма, която приема естествено число n и изписва стълба от 1 до n + +Пример +Вход: +5 +Изход: +1 +12 +123 +1234 +12345 + +2.Да се състави програма, която по въведено естествено число n да изведе всички естествени решения на уравнението x + y = n. + +Пример +Вход: +4 +Изход: +x = 1 y = 3 +x = 2 y = 2 +x = 3 y = 1 + + +3.Напишете програма, която по въведено цяло положително число, извежда квадратът на това число, но в обратен ред, като водещите нули се игнорират. + +Пример +Вход: +10 +Изход: +1 + +Вход: +25 +Изход: +526 + +4.Напишете програма, която приема от потребителя две цели положителни числа - *m* и *n*. + Програмата да отпечата числатаот 1 до m*n, като на всеки ред има по *n* числа (тоест ще отпечатате *m* реда). + Печатайте числата по редове: + +Пример +Вход: +2 3 +Изход: +1 2 3 +4 5 6 + +5.Напишете проста игра, в която първо се въвежда цяло число в интервала [0;100] и в последствие се въвеждат цели числа + (предположения), като за всяко се казва дали е по - малко или по - голямо от първоначално ваведеното. + Tова продължава до въвеждане на число, равно на първоначалното. Програмата да отпечата и броят направени предположения. + +6.Напишете програма, която иска от потребителя поредица от цели числа по - големи от 0. + Въвеждането приключва с въвеждане на 0. Гарантирано е, че всяко от числата е въведено **точно два пъти** освен едно, + което е въведено **точно веднъж**. Програмата да изведе кое е това число. + +7.Да се състави програма, която по въведено естествено число N намира и отпечатва всички тройки естествени числа a, b и c, + не по-големи от N, които могат да бъдат страни на правоъгълен триъгълник. + +Пример +Вход: +11 +Изход +3 4 5 +6 8 10 + +8.Напишете програма, която иска от потребителя вход цифра N[2;9] и символ S.Програмата да извежда фигура съставена от символа във вид на ромб, както е показано на примерите. + +Пример +Вход: +5 * +Изход + * + *** + ***** + ******* +********* + ******* + ***** + *** + * + +*Бонус* +Задача ЕЛЕКТРОНЕН ЧАСОВНИК +В големия нов МОЛ в града на програмистите се повредили част от цифрите на електронния часовник. +Повредени били първата цифра от числото, което показва часовете, втората цифра на числото, което показва минутите и първата цифра на числото, което показва секундите. +Вместо тях на екрана се появявал знака *. +Когато Коко и приятелите му ходели на кино, те не успявали да преценят точно колко е часа. +Все пак, момчетата си създали система за изчисление, която приблизително точно им показвало времето. +Те успявали да предвидят колко е показвал часовника в началото и края на филма, в случай че знаят точно колко време е минало. +Срещу името на всеки филм на входа на киното е дадено неговото времетраене в часове, минути и секунди. +Пресмятанията доста затрудняват момчетата и затова на тях ще им е по-удобно това да се прави с компютърна програма. +Те не разбират много от програмиране и затова вие трябва да напишете програма clock, която помага на Коко и приятелите му. + +Вход: +На първия ред на стандартния вход е записана последователност от цифри и знака *, която показва какво се вижда на екрана на часовника в началото на филма. +На втория ред е записана подобна последователност за показанието на часовника в края на филма. +На третия ред се въвежда продължителността на филма в часове, минути и секунди. +Часовникът е настроен така, че показва времето по 12-часова скала, а не по 24-часова. + +Изход: +На стандартния изход изведете всички възможни показания на часовника за началото и края на филма. +Всяка двойка с начален и краен час се извежда на един ред, като първо се извежда началното показание във формат hh:mm:ss, и след един интервал крайното показание в същия формат. +Ако такива показания на часовника не са възможни, да се изведе “Impossible”. + +Ограничения: +Продължителността на филма е не по-голяма 12 часа. + +Примери: + +Вход: +*25**6 +*10**2 +10 19 26 +Изход: +02:50:06 01:09:32 +02:50:16 01:09:42 +02:50:26 01:09:52 +12:50:06 11:09:32 +12:50:16 11:09:42 +12:50:26 11:09:52 + +Вход: +*95**6 +*21**2 +4 12 6 +Изход: +Impossible -- cgit v1.3.1-23-gd82d From 653bd0b31519cf279e402fd177a40bafbcffc897 Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Thu, 28 Oct 2021 17:37:38 +0300 Subject: Update Pract 01-03. Rename --- pract_SI/Pract. 01/Solutions/task1.cpp | 12 +++++ pract_SI/Pract. 01/Solutions/task2.cpp | 17 ++++++++ pract_SI/Pract. 01/Solutions/task3.cpp | 16 +++++++ pract_SI/Pract. 01/Solutions/task4.cpp | 23 ++++++++++ pract_SI/Pract. 01/Solutions/task5.cpp | 16 +++++++ pract_SI/Pract. 02/Solutions/task1.cpp | 20 +++++++++ pract_SI/Pract. 02/Solutions/task2.cpp | 29 ++++++++++++ .../Pract. 02/Solutions/task3 - no EPSILON.cpp | 23 ++++++++++ .../Pract. 02/Solutions/task3 - with EPSILON.cpp | 24 ++++++++++ pract_SI/Pract. 02/Solutions/task4.cpp | 26 +++++++++++ pract_SI/Pract. 02/Solutions/task5.cpp | 51 ++++++++++++++++++++++ pract_SI/Pract. 02/Solutions/task6.cpp | 42 ++++++++++++++++++ pract_SI/Pract. 02/Solutions/task7.cpp | 44 +++++++++++++++++++ 13 files changed, 343 insertions(+) create mode 100644 pract_SI/Pract. 01/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task2.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task3.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task2.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task6.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task7.cpp (limited to 'pract_SI') diff --git a/pract_SI/Pract. 01/Solutions/task1.cpp b/pract_SI/Pract. 01/Solutions/task1.cpp new file mode 100644 index 0000000..54a1902 --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task1.cpp @@ -0,0 +1,12 @@ +#include +#include +using namespace std; +int main() +{ + string name; + cout << "What is your name?\n"; + cin >> name; + cout << "Hello, " << name << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task2.cpp b/pract_SI/Pract. 01/Solutions/task2.cpp new file mode 100644 index 0000000..554653d --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task2.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +int main() +{ + double x, y; + + cout << "First side: "; + cin >> x; + + cout << "Second side: "; + cin >> y; + + cout << "Parameter: " << 2 * (x + y) << endl; + cout << "Area: " << x * y << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task3.cpp b/pract_SI/Pract. 01/Solutions/task3.cpp new file mode 100644 index 0000000..830348b --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task3.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +int main() +{ + double a, b; + + cout << "First number: "; + cin >> a; + + cout << "Second number: "; + cin >> b; + + cout << boolalpha << (a < b) << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task4.cpp b/pract_SI/Pract. 01/Solutions/task4.cpp new file mode 100644 index 0000000..b4829b4 --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task4.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +int main() +{ + double x1, y1, x2, y2; + + cout << "x1: "; + cin >> x1; + + cout << "y1: "; + cin >> y1; + + cout << "x2: "; + cin >> x2; + + cout << "y2: "; + cin >> y2; + + cout << round(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) * 100) / 100 << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task5.cpp b/pract_SI/Pract. 01/Solutions/task5.cpp new file mode 100644 index 0000000..931178d --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task5.cpp @@ -0,0 +1,16 @@ +#include +#include +#include +using namespace std; +int main() +{ + string card_number; + + cout << "Card number: "; + cin >> card_number; + + cout << "Hidden card number: " << setfill('X') << setw(13) + << card_number[12] << card_number[13] << card_number[14] << card_number[15] << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task1.cpp b/pract_SI/Pract. 02/Solutions/task1.cpp new file mode 100644 index 0000000..3a60fad --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task1.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +int main() +{ + int year; + + cout << "Enter an year to check: "; + cin >> year; + + cout << year << " is"; + + if (!(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) + { + cout << " not"; + } + + cout << " leap!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task2.cpp b/pract_SI/Pract. 02/Solutions/task2.cpp new file mode 100644 index 0000000..a1ddcf8 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task2.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +int main() +{ + char inputCharacter; + + cout << "Enter a character to test: "; + cin >> inputCharacter; + + cout << inputCharacter << " is "; + if (inputCharacter == 'a' || inputCharacter == 'e' || inputCharacter == 'i' || inputCharacter == 'o' || inputCharacter == 'u' || + inputCharacter == 'A' || inputCharacter == 'E' || inputCharacter == 'I' || inputCharacter == 'O' || inputCharacter == 'U') + { + cout << "a vowel!\n"; + } + else + { + if ((inputCharacter >= 'a' && inputCharacter <= 'z') || (inputCharacter >= 'A' && inputCharacter <= 'Z')) + { + cout << "a consonant!\n"; + } + else + { + cout << "is not a letter from the English alphabet!\n"; + } + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp b/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp new file mode 100644 index 0000000..6c9f832 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +int main() +{ + double x, y; + + cout << "Enter the first number: "; + cin >> x; + + cout << "Enter the second number: "; + cin >> y; + + if (fabs(x - y) < 0.000001) + { + cout << "Numbers must be different!\n"; + return 1; + } + + cout << (x < y ? y : x) << " is the greater number!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp b/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp new file mode 100644 index 0000000..dcd5f88 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp @@ -0,0 +1,24 @@ +#include +#include +using namespace std; + +int main() +{ + double num1, num2; + + cout << "Enter the first number: "; + cin >> num1; + + cout << "Enter the second number: "; + cin >> num2; + + if (fabs(num1 - num2) <= DBL_EPSILON * fabs(num1)) + { + cout << "Numbers must be different!\n"; + return 1; + } + + cout << (num1 > num2 ? "First" : "Second") << " is the greater number!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task4.cpp b/pract_SI/Pract. 02/Solutions/task4.cpp new file mode 100644 index 0000000..acb471c --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task4.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; +int main() +{ + double a, b, c; + + cout << "First side: "; + cin >> a; + + cout << "Second side: "; + cin >> b; + + cout << "Third side: "; + cin >> c; + + if ((a + b > c) && (a + c > b) && (b + c > a)) + { + cout << "Triangle is valid.\n"; + } + else + { + cout << "Triangle is not valid.\n"; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task5.cpp b/pract_SI/Pract. 02/Solutions/task5.cpp new file mode 100644 index 0000000..419d6d4 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task5.cpp @@ -0,0 +1,51 @@ +#include +#include +using namespace std; +int main() +{ + double a, b, c; + double root1, root2, imaginary; + double discriminant; + + cout << "Finding the root of the equation a * x^2 + b * x + c = 0\n"; + + cout << "Enter the value of a: "; + cin >> a; + + if (a < 0.00000001) + { + cout << "If a is 0, then this is not a quadratic equation!\n"; + return 1; + } + + cout << "Enter the value of b: "; + cin >> b; + + cout << "Enter the value of c: "; + cin >> c; + + discriminant = (b * b) - (4 * a * c); + + if (discriminant > 0) + { + root1 = (-b + sqrt(discriminant)) / (2 * a); + root2 = (-b - sqrt(discriminant)) / (2 * a); + + cout << "Two distinct and real roots exist: " << root1 << " and " << root2 << endl; + } + else if (discriminant == 0) + { + root1 = root2 = -b / (2 * a); + + cout << "Two equal and real roots exist: " << root1 << " and " << root2 << endl; + } + else if (discriminant < 0) + { + root1 = root2 = -b / (2 * a); + imaginary = sqrt(-discriminant) / (2 * a); + + cout << "Two distinct complex roots exist: " << root1 << "+" << imaginary << "i and " << root2 << "-" << imaginary << "i\n"; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task6.cpp b/pract_SI/Pract. 02/Solutions/task6.cpp new file mode 100644 index 0000000..a7484b2 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task6.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; +int main() +{ + double a, b; + char operation; + + cout << "Enter the first number: "; + cin >> a; + + cout << "Enter the second number: "; + cin >> b; + + cout << "Choose operation: +, -, / or *: "; + cin >> operation; + + switch (operation) + { + case '+': + cout << "Result: " << a + b << endl; + break; + case '-': + cout << "Result: " << a - b << endl; + break; + case '*': + cout << "Result: " << a * b << endl; + break; + case '/': + if (b < 0.0000001) + { + cout << "You can not divide by zero!\n"; + return 1; + } + cout << "Result: " << a / b << endl; + break; + default: + cout << "Invalid operation!\n"; + break; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task7.cpp b/pract_SI/Pract. 02/Solutions/task7.cpp new file mode 100644 index 0000000..3c22a83 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task7.cpp @@ -0,0 +1,44 @@ +#include +using namespace std; +int main() +{ + // you can use int as well, but do you really need something as big as int? + short number; + unsigned char digit1, digit2, digit3, digit4, number1, number2; + + cout << "Enter a 4-digit number: "; + cin >> number; + + if (number < 1000 || number > 10000) + { + cout << "The input must be a 4-digit number!\n"; + return 1; + } + + digit1 = number / 1000; + digit2 = number / 100 % 10; + digit3 = number / 10 % 10; + digit4 = number % 10; + + number1 = digit1 * 10 + digit4; + number2 = digit2 * 10 + digit3; + + if (number1 < number2) + { + cout << "less (" << (int)number1 << " < " << (int)number2 << ")\n"; + } + else + { + if (number1 == number2) + { + cout << "equal (" << (int)number1 << " = " << (int)number2 << ")\n"; + } + else + { + cout << "greater (" << (int)number1 << " > " << (int)number2 << ")\n"; + } + } + + + return 0; +} \ No newline at end of file -- cgit v1.3.1-23-gd82d From f61a51c13a36ccf11b26651787be079861c50ea4 Mon Sep 17 00:00:00 2001 From: Justsvetoslavov <50053338+Justsvetoslavov@users.noreply.github.com> Date: Thu, 28 Oct 2021 17:38:38 +0300 Subject: Delete pract_SI directory --- pract_SI/Pract. 01/Solutions/task1.cpp | 12 -- pract_SI/Pract. 01/Solutions/task2.cpp | 17 --- pract_SI/Pract. 01/Solutions/task3.cpp | 16 --- pract_SI/Pract. 01/Solutions/task4.cpp | 23 ---- pract_SI/Pract. 01/Solutions/task5.cpp | 16 --- pract_SI/Pract. 02/Solutions/task1.cpp | 20 ---- pract_SI/Pract. 02/Solutions/task2.cpp | 29 ----- .../Pract. 02/Solutions/task3 - no EPSILON.cpp | 23 ---- .../Pract. 02/Solutions/task3 - with EPSILON.cpp | 24 ---- pract_SI/Pract. 02/Solutions/task4.cpp | 26 ---- pract_SI/Pract. 02/Solutions/task5.cpp | 51 -------- pract_SI/Pract. 02/Solutions/task6.cpp | 42 ------- pract_SI/Pract. 02/Solutions/task7.cpp | 44 ------- pract_SI/Pract. 03/Solutions/task1.cpp | 19 --- pract_SI/Pract. 03/Solutions/task2.cpp | 17 --- pract_SI/Pract. 03/Solutions/task3.cpp | 22 ---- pract_SI/Pract. 03/Solutions/task4.cpp | 21 ---- pract_SI/Pract. 03/Solutions/task5.cpp | 41 ------- pract_SI/Pract. 03/Solutions/task6.cpp | 18 --- pract_SI/Pract. 03/Solutions/task7.cpp | 30 ----- pract_SI/Pract. 03/Solutions/task8.cpp | 41 ------- pract_SI/Pract. 03/Solutions/task9.cpp | 59 ---------- pract_SI/Pract. 03/Startup_tasks.txt | 7 -- pract_SI/Pract. 03/Tasks3.txt | 131 --------------------- pract_SI/pract. 01/Tasks_1.txt | 20 ---- pract_SI/pract. 01/task1.cpp | 12 -- pract_SI/pract. 01/task2.cpp | 17 --- pract_SI/pract. 01/task3.cpp | 16 --- pract_SI/pract. 01/task4.cpp | 23 ---- pract_SI/pract. 01/task5.cpp | 16 --- pract_SI/pract. 02/Tasks_2.txt | 37 ------ pract_SI/pract. 02/task1.cpp | 20 ---- pract_SI/pract. 02/task2.cpp | 29 ----- pract_SI/pract. 02/task3 - no EPSILON.cpp | 23 ---- pract_SI/pract. 02/task3 - with EPSILON.cpp | 24 ---- pract_SI/pract. 02/task4.cpp | 26 ---- pract_SI/pract. 02/task5.cpp | 51 -------- pract_SI/pract. 02/task6.cpp | 42 ------- pract_SI/pract. 02/task7.cpp | 44 ------- 39 files changed, 1149 deletions(-) delete mode 100644 pract_SI/Pract. 01/Solutions/task1.cpp delete mode 100644 pract_SI/Pract. 01/Solutions/task2.cpp delete mode 100644 pract_SI/Pract. 01/Solutions/task3.cpp delete mode 100644 pract_SI/Pract. 01/Solutions/task4.cpp delete mode 100644 pract_SI/Pract. 01/Solutions/task5.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task1.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task2.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task4.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task5.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task6.cpp delete mode 100644 pract_SI/Pract. 02/Solutions/task7.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task1.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task2.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task3.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task4.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task5.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task6.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task7.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task8.cpp delete mode 100644 pract_SI/Pract. 03/Solutions/task9.cpp delete mode 100644 pract_SI/Pract. 03/Startup_tasks.txt delete mode 100644 pract_SI/Pract. 03/Tasks3.txt delete mode 100644 pract_SI/pract. 01/Tasks_1.txt delete mode 100644 pract_SI/pract. 01/task1.cpp delete mode 100644 pract_SI/pract. 01/task2.cpp delete mode 100644 pract_SI/pract. 01/task3.cpp delete mode 100644 pract_SI/pract. 01/task4.cpp delete mode 100644 pract_SI/pract. 01/task5.cpp delete mode 100644 pract_SI/pract. 02/Tasks_2.txt delete mode 100644 pract_SI/pract. 02/task1.cpp delete mode 100644 pract_SI/pract. 02/task2.cpp delete mode 100644 pract_SI/pract. 02/task3 - no EPSILON.cpp delete mode 100644 pract_SI/pract. 02/task3 - with EPSILON.cpp delete mode 100644 pract_SI/pract. 02/task4.cpp delete mode 100644 pract_SI/pract. 02/task5.cpp delete mode 100644 pract_SI/pract. 02/task6.cpp delete mode 100644 pract_SI/pract. 02/task7.cpp (limited to 'pract_SI') diff --git a/pract_SI/Pract. 01/Solutions/task1.cpp b/pract_SI/Pract. 01/Solutions/task1.cpp deleted file mode 100644 index 54a1902..0000000 --- a/pract_SI/Pract. 01/Solutions/task1.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - string name; - cout << "What is your name?\n"; - cin >> name; - cout << "Hello, " << name << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task2.cpp b/pract_SI/Pract. 01/Solutions/task2.cpp deleted file mode 100644 index 554653d..0000000 --- a/pract_SI/Pract. 01/Solutions/task2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -using namespace std; -int main() -{ - double x, y; - - cout << "First side: "; - cin >> x; - - cout << "Second side: "; - cin >> y; - - cout << "Parameter: " << 2 * (x + y) << endl; - cout << "Area: " << x * y << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task3.cpp b/pract_SI/Pract. 01/Solutions/task3.cpp deleted file mode 100644 index 830348b..0000000 --- a/pract_SI/Pract. 01/Solutions/task3.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -using namespace std; -int main() -{ - double a, b; - - cout << "First number: "; - cin >> a; - - cout << "Second number: "; - cin >> b; - - cout << boolalpha << (a < b) << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task4.cpp b/pract_SI/Pract. 01/Solutions/task4.cpp deleted file mode 100644 index b4829b4..0000000 --- a/pract_SI/Pract. 01/Solutions/task4.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - double x1, y1, x2, y2; - - cout << "x1: "; - cin >> x1; - - cout << "y1: "; - cin >> y1; - - cout << "x2: "; - cin >> x2; - - cout << "y2: "; - cin >> y2; - - cout << round(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) * 100) / 100 << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task5.cpp b/pract_SI/Pract. 01/Solutions/task5.cpp deleted file mode 100644 index 931178d..0000000 --- a/pract_SI/Pract. 01/Solutions/task5.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -using namespace std; -int main() -{ - string card_number; - - cout << "Card number: "; - cin >> card_number; - - cout << "Hidden card number: " << setfill('X') << setw(13) - << card_number[12] << card_number[13] << card_number[14] << card_number[15] << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task1.cpp b/pract_SI/Pract. 02/Solutions/task1.cpp deleted file mode 100644 index 3a60fad..0000000 --- a/pract_SI/Pract. 02/Solutions/task1.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -using namespace std; -int main() -{ - int year; - - cout << "Enter an year to check: "; - cin >> year; - - cout << year << " is"; - - if (!(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) - { - cout << " not"; - } - - cout << " leap!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task2.cpp b/pract_SI/Pract. 02/Solutions/task2.cpp deleted file mode 100644 index a1ddcf8..0000000 --- a/pract_SI/Pract. 02/Solutions/task2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -using namespace std; -int main() -{ - char inputCharacter; - - cout << "Enter a character to test: "; - cin >> inputCharacter; - - cout << inputCharacter << " is "; - if (inputCharacter == 'a' || inputCharacter == 'e' || inputCharacter == 'i' || inputCharacter == 'o' || inputCharacter == 'u' || - inputCharacter == 'A' || inputCharacter == 'E' || inputCharacter == 'I' || inputCharacter == 'O' || inputCharacter == 'U') - { - cout << "a vowel!\n"; - } - else - { - if ((inputCharacter >= 'a' && inputCharacter <= 'z') || (inputCharacter >= 'A' && inputCharacter <= 'Z')) - { - cout << "a consonant!\n"; - } - else - { - cout << "is not a letter from the English alphabet!\n"; - } - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp b/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp deleted file mode 100644 index 6c9f832..0000000 --- a/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - double x, y; - - cout << "Enter the first number: "; - cin >> x; - - cout << "Enter the second number: "; - cin >> y; - - if (fabs(x - y) < 0.000001) - { - cout << "Numbers must be different!\n"; - return 1; - } - - cout << (x < y ? y : x) << " is the greater number!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp b/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp deleted file mode 100644 index dcd5f88..0000000 --- a/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -using namespace std; - -int main() -{ - double num1, num2; - - cout << "Enter the first number: "; - cin >> num1; - - cout << "Enter the second number: "; - cin >> num2; - - if (fabs(num1 - num2) <= DBL_EPSILON * fabs(num1)) - { - cout << "Numbers must be different!\n"; - return 1; - } - - cout << (num1 > num2 ? "First" : "Second") << " is the greater number!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task4.cpp b/pract_SI/Pract. 02/Solutions/task4.cpp deleted file mode 100644 index acb471c..0000000 --- a/pract_SI/Pract. 02/Solutions/task4.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -using namespace std; -int main() -{ - double a, b, c; - - cout << "First side: "; - cin >> a; - - cout << "Second side: "; - cin >> b; - - cout << "Third side: "; - cin >> c; - - if ((a + b > c) && (a + c > b) && (b + c > a)) - { - cout << "Triangle is valid.\n"; - } - else - { - cout << "Triangle is not valid.\n"; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task5.cpp b/pract_SI/Pract. 02/Solutions/task5.cpp deleted file mode 100644 index 419d6d4..0000000 --- a/pract_SI/Pract. 02/Solutions/task5.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - double a, b, c; - double root1, root2, imaginary; - double discriminant; - - cout << "Finding the root of the equation a * x^2 + b * x + c = 0\n"; - - cout << "Enter the value of a: "; - cin >> a; - - if (a < 0.00000001) - { - cout << "If a is 0, then this is not a quadratic equation!\n"; - return 1; - } - - cout << "Enter the value of b: "; - cin >> b; - - cout << "Enter the value of c: "; - cin >> c; - - discriminant = (b * b) - (4 * a * c); - - if (discriminant > 0) - { - root1 = (-b + sqrt(discriminant)) / (2 * a); - root2 = (-b - sqrt(discriminant)) / (2 * a); - - cout << "Two distinct and real roots exist: " << root1 << " and " << root2 << endl; - } - else if (discriminant == 0) - { - root1 = root2 = -b / (2 * a); - - cout << "Two equal and real roots exist: " << root1 << " and " << root2 << endl; - } - else if (discriminant < 0) - { - root1 = root2 = -b / (2 * a); - imaginary = sqrt(-discriminant) / (2 * a); - - cout << "Two distinct complex roots exist: " << root1 << "+" << imaginary << "i and " << root2 << "-" << imaginary << "i\n"; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task6.cpp b/pract_SI/Pract. 02/Solutions/task6.cpp deleted file mode 100644 index a7484b2..0000000 --- a/pract_SI/Pract. 02/Solutions/task6.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -using namespace std; -int main() -{ - double a, b; - char operation; - - cout << "Enter the first number: "; - cin >> a; - - cout << "Enter the second number: "; - cin >> b; - - cout << "Choose operation: +, -, / or *: "; - cin >> operation; - - switch (operation) - { - case '+': - cout << "Result: " << a + b << endl; - break; - case '-': - cout << "Result: " << a - b << endl; - break; - case '*': - cout << "Result: " << a * b << endl; - break; - case '/': - if (b < 0.0000001) - { - cout << "You can not divide by zero!\n"; - return 1; - } - cout << "Result: " << a / b << endl; - break; - default: - cout << "Invalid operation!\n"; - break; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task7.cpp b/pract_SI/Pract. 02/Solutions/task7.cpp deleted file mode 100644 index 3c22a83..0000000 --- a/pract_SI/Pract. 02/Solutions/task7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -using namespace std; -int main() -{ - // you can use int as well, but do you really need something as big as int? - short number; - unsigned char digit1, digit2, digit3, digit4, number1, number2; - - cout << "Enter a 4-digit number: "; - cin >> number; - - if (number < 1000 || number > 10000) - { - cout << "The input must be a 4-digit number!\n"; - return 1; - } - - digit1 = number / 1000; - digit2 = number / 100 % 10; - digit3 = number / 10 % 10; - digit4 = number % 10; - - number1 = digit1 * 10 + digit4; - number2 = digit2 * 10 + digit3; - - if (number1 < number2) - { - cout << "less (" << (int)number1 << " < " << (int)number2 << ")\n"; - } - else - { - if (number1 == number2) - { - cout << "equal (" << (int)number1 << " = " << (int)number2 << ")\n"; - } - else - { - cout << "greater (" << (int)number1 << " > " << (int)number2 << ")\n"; - } - } - - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task1.cpp b/pract_SI/Pract. 03/Solutions/task1.cpp deleted file mode 100644 index ae955a8..0000000 --- a/pract_SI/Pract. 03/Solutions/task1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "pch.h" -#include - -using namespace std; - -int main() -{ - unsigned long long number; - cin >> number; - - for (int i = 1; i <= number; i++) - { - for (int j = 1; j <= i; j++) - cout << j; - cout << endl; - } - - return 0; -} diff --git a/pract_SI/Pract. 03/Solutions/task2.cpp b/pract_SI/Pract. 03/Solutions/task2.cpp deleted file mode 100644 index b3e970d..0000000 --- a/pract_SI/Pract. 03/Solutions/task2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include - -using namespace std; - -int main() -{ - unsigned long long number; - cin >> number; - - for (unsigned long long x = 1, y = number; x < number; x++) - { - cout << "x = " << x << " " - << "y = " << --y << endl; - } - - return 0; -} diff --git a/pract_SI/Pract. 03/Solutions/task3.cpp b/pract_SI/Pract. 03/Solutions/task3.cpp deleted file mode 100644 index a6a6362..0000000 --- a/pract_SI/Pract. 03/Solutions/task3.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned long long oldNumber, newNumber; - - cout << "Enter a positive number: "; - cin >> oldNumber; - - oldNumber *= oldNumber; - newNumber = 0; - - while (oldNumber != 0) - { - newNumber = newNumber * 10 + oldNumber % 10; - oldNumber /= 10; - } - - cout << newNumber << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task4.cpp b/pract_SI/Pract. 03/Solutions/task4.cpp deleted file mode 100644 index 622b8a1..0000000 --- a/pract_SI/Pract. 03/Solutions/task4.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned int m, n; - cout << "Number of rows: "; - cin >> m; - cout << "Number of columns: "; - cin >> n; - - for (unsigned int i = 1; i <= m * n; i++) - { - cout << i << " "; - if (i % n == 0) - { - cout << endl; - } - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task5.cpp b/pract_SI/Pract. 03/Solutions/task5.cpp deleted file mode 100644 index d6ac57c..0000000 --- a/pract_SI/Pract. 03/Solutions/task5.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned short number, guess; - unsigned int counter = 0; - - cout << "Enter a number between 0 and 100: "; - cin >> number; - if (number < 0 || number > 100) - { - cout << "Invalid input!\n"; - return 1; - } - - do - { - ++counter; - - cout << "Guess " << counter << ": "; - cin >> guess; - if (guess < 0 || guess > 100) - { - cout << "Invalid input!\n"; - return 2; - } - - if (guess < number) - { - cout << "The number you are looking for is greater than your guess!\n"; - } - else if (guess > number) - { - cout << "The number you are looking for is less than your guess!\n"; - } - } while (guess != number); - - cout << "You found the number in " << counter << " attempt(s)!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task6.cpp b/pract_SI/Pract. 03/Solutions/task6.cpp deleted file mode 100644 index 8d0beac..0000000 --- a/pract_SI/Pract. 03/Solutions/task6.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -using namespace std; -int main() -{ - unsigned int number = 0, input = 1; - - while(input != 0) - { - cout << "Enter a positive number: "; - cin >> input; - - number ^= input; - } - - cout << "The single number is " << number << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task7.cpp b/pract_SI/Pract. 03/Solutions/task7.cpp deleted file mode 100644 index aa9194b..0000000 --- a/pract_SI/Pract. 03/Solutions/task7.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#define LIMIT 5 -#define SEPARATOR " " - -using namespace std; - -//const short LIMIT = 5; -//const char SEPARATOR = ' '; - - -int main() -{ - unsigned long long N; - cin >> N; - - if (N < LIMIT) - return -1; - - for (int c = 1; c <= N; c++) { - for (int b = 1; b < c; b++) { - for (int a = 1; a < b; a++) { - if ((a * a) + (b * b) == (c * c)) { - cout << a << SEPARATOR << b << SEPARATOR << c << endl; - } - } - } - } - - return 0; -} diff --git a/pract_SI/Pract. 03/Solutions/task8.cpp b/pract_SI/Pract. 03/Solutions/task8.cpp deleted file mode 100644 index 3f32ebf..0000000 --- a/pract_SI/Pract. 03/Solutions/task8.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include - -using namespace std; - -const short LOWERLIMIT = 2; -const short UPPERLIMIT = 9; -const char SEPARATOR = ' '; - -int main() -{ - short N; - char S; - cin >> N >> S; - - if (N < LOWERLIMIT || N > UPPERLIMIT) - return -1; //end program - - for (int i = 1; i <= N; i++) - { - for (int j = N - i; j > 0; j--) - cout << SEPARATOR; - - for (int k = 1; k < 2 * i; k++) - cout << S; - - cout << endl; - } - - for (int i = 1; i < N; i++) - { - for (int j = 1; j <= i; j++) - cout << SEPARATOR; - - for (int k = 1; k < 2 * (N - i); k++) - cout << S; - - cout << endl; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task9.cpp b/pract_SI/Pract. 03/Solutions/task9.cpp deleted file mode 100644 index 9f1f054..0000000 --- a/pract_SI/Pract. 03/Solutions/task9.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include - -int main() { - - // по-нататък ще учим как се вкарват сложни данни, затова сега ще ги hardcode-нем в main-а - - int hoursOnesStart = 2, minutesTensStart = 5, secondsOnesStart = 6; - int hoursOnesFinal = 1, minutesTensFinal = 0, secondsOnesFinal = 2; - int hoursDelta = 10, minutesDelta = 19, secondsDelta = 26; - - for (size_t hoursTensStart = 0; hoursTensStart <= 1; ++hoursTensStart) - { - for (size_t minutesOnesStart = 0; minutesOnesStart <= 9; ++minutesOnesStart) - { - for (size_t secondsTensStart = 0; secondsTensStart <= 5; secondsTensStart++) - { - int hoursTemp = hoursTensStart * 10 + hoursOnesStart; - int minutesTemp = minutesTensStart * 10 + minutesOnesStart; - int secondsTemp = secondsTensStart * 10 + secondsOnesStart; - - secondsTemp += secondsDelta; - if (secondsTemp >= 60) { - minutesTemp += secondsTemp / 60; - secondsTemp %= 60; - } - - minutesTemp += minutesDelta; - if (minutesTemp >= 60) { - hoursTemp += minutesTemp / 60; - minutesTemp %= 60; - } - - hoursTemp += hoursDelta; - if (hoursTemp > 12) { - hoursTemp %= 12; - } - - bool hoursOnesMatch = hoursTemp % 10 == hoursOnesFinal, - minutesTensMatch = minutesTemp / 10 == minutesTensFinal, - secondsOnesMatch = secondsTemp % 10 == secondsOnesFinal; - - if (hoursOnesMatch && minutesTensMatch && secondsOnesMatch) { - int hoursTensFinal = hoursTemp / 10, - minutesOnesFinal = minutesTemp % 10, - secondsTensFinal = secondsTemp / 10; - - std::cout << hoursTensStart << hoursOnesStart << ':' - << minutesTensStart << minutesOnesStart << ':' - << secondsTensStart << secondsOnesStart << ' ' - << hoursTensFinal << hoursOnesFinal << ':' - << minutesTensFinal << minutesOnesFinal << ':' - << secondsTensFinal << secondsOnesFinal << '\n'; - } - } - } - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Startup_tasks.txt b/pract_SI/Pract. 03/Startup_tasks.txt deleted file mode 100644 index 8ee6d58..0000000 --- a/pract_SI/Pract. 03/Startup_tasks.txt +++ /dev/null @@ -1,7 +0,0 @@ -1.Напишете програма , която приема като вход N лева.Да се отпечата как бихме разпределили сумата на банкноти, -така че да имаме минимален брой банкноти. (Да не се използват условни оператори и цикли) -Пояснение: Нека да приемем, че имаме банкноти с 1лв и 2лв. - -2.Напишете програма, която приема като вход цяло положително число V, което ще отговаря на скорост. -Програмата да отпечатва колко е глобата от КАТ, а ако няма глоба следното съобщение "No speedticket". -(https://stamatovandpartners.com/elektronen-fish-za-previshena-skorost/) \ No newline at end of file diff --git a/pract_SI/Pract. 03/Tasks3.txt b/pract_SI/Pract. 03/Tasks3.txt deleted file mode 100644 index 64c5c4c..0000000 --- a/pract_SI/Pract. 03/Tasks3.txt +++ /dev/null @@ -1,131 +0,0 @@ -#Никола Светославов - task3 - -## Задачи - -1.Да се напише програма, която приема естествено число n и изписва стълба от 1 до n - -Пример -Вход: -5 -Изход: -1 -12 -123 -1234 -12345 - -2.Да се състави програма, която по въведено естествено число n да изведе всички естествени решения на уравнението x + y = n. - -Пример -Вход: -4 -Изход: -x = 1 y = 3 -x = 2 y = 2 -x = 3 y = 1 - - -3.Напишете програма, която по въведено цяло положително число, извежда квадратът на това число, но в обратен ред, като водещите нули се игнорират. - -Пример -Вход: -10 -Изход: -1 - -Вход: -25 -Изход: -526 - -4.Напишете програма, която приема от потребителя две цели положителни числа - *m* и *n*. - Програмата да отпечата числатаот 1 до m*n, като на всеки ред има по *n* числа (тоест ще отпечатате *m* реда). - Печатайте числата по редове: - -Пример -Вход: -2 3 -Изход: -1 2 3 -4 5 6 - -5.Напишете проста игра, в която първо се въвежда цяло число в интервала [0;100] и в последствие се въвеждат цели числа - (предположения), като за всяко се казва дали е по - малко или по - голямо от първоначално ваведеното. - Tова продължава до въвеждане на число, равно на първоначалното. Програмата да отпечата и броят направени предположения. - -6.Напишете програма, която иска от потребителя поредица от цели числа по - големи от 0. - Въвеждането приключва с въвеждане на 0. Гарантирано е, че всяко от числата е въведено **точно два пъти** освен едно, - което е въведено **точно веднъж**. Програмата да изведе кое е това число. - -7.Да се състави програма, която по въведено естествено число N намира и отпечатва всички тройки естествени числа a, b и c, - не по-големи от N, които могат да бъдат страни на правоъгълен триъгълник. - -Пример -Вход: -11 -Изход -3 4 5 -6 8 10 - -8.Напишете програма, която иска от потребителя вход цифра N[2;9] и символ S.Програмата да извежда фигура съставена от символа във вид на ромб, както е показано на примерите. - -Пример -Вход: -5 * -Изход - * - *** - ***** - ******* -********* - ******* - ***** - *** - * - -*Бонус* -Задача ЕЛЕКТРОНЕН ЧАСОВНИК -В големия нов МОЛ в града на програмистите се повредили част от цифрите на електронния часовник. -Повредени били първата цифра от числото, което показва часовете, втората цифра на числото, което показва минутите и първата цифра на числото, което показва секундите. -Вместо тях на екрана се появявал знака *. -Когато Коко и приятелите му ходели на кино, те не успявали да преценят точно колко е часа. -Все пак, момчетата си създали система за изчисление, която приблизително точно им показвало времето. -Те успявали да предвидят колко е показвал часовника в началото и края на филма, в случай че знаят точно колко време е минало. -Срещу името на всеки филм на входа на киното е дадено неговото времетраене в часове, минути и секунди. -Пресмятанията доста затрудняват момчетата и затова на тях ще им е по-удобно това да се прави с компютърна програма. -Те не разбират много от програмиране и затова вие трябва да напишете програма clock, която помага на Коко и приятелите му. - -Вход: -На първия ред на стандартния вход е записана последователност от цифри и знака *, която показва какво се вижда на екрана на часовника в началото на филма. -На втория ред е записана подобна последователност за показанието на часовника в края на филма. -На третия ред се въвежда продължителността на филма в часове, минути и секунди. -Часовникът е настроен така, че показва времето по 12-часова скала, а не по 24-часова. - -Изход: -На стандартния изход изведете всички възможни показания на часовника за началото и края на филма. -Всяка двойка с начален и краен час се извежда на един ред, като първо се извежда началното показание във формат hh:mm:ss, и след един интервал крайното показание в същия формат. -Ако такива показания на часовника не са възможни, да се изведе “Impossible”. - -Ограничения: -Продължителността на филма е не по-голяма 12 часа. - -Примери: - -Вход: -*25**6 -*10**2 -10 19 26 -Изход: -02:50:06 01:09:32 -02:50:16 01:09:42 -02:50:26 01:09:52 -12:50:06 11:09:32 -12:50:16 11:09:42 -12:50:26 11:09:52 - -Вход: -*95**6 -*21**2 -4 12 6 -Изход: -Impossible diff --git a/pract_SI/pract. 01/Tasks_1.txt b/pract_SI/pract. 01/Tasks_1.txt deleted file mode 100644 index bb7ee2d..0000000 --- a/pract_SI/pract. 01/Tasks_1.txt +++ /dev/null @@ -1,20 +0,0 @@ -Никола Светославов - task1 - -## Задачи -1.Напишете програма, която пита потребителя за името му, след което отпечатва "Hello, <име>" - -2.Напишете програма, която подканя потребителя да въведе дължините на двете страни на правоъгълник - **като му извежда съобщение, например "Please enter the length of the first side:"** - Програмата да изведе периметърът и лицето на този правоъгълник. - **Страните може да не са цели числа!** - -3.Напишете програма, която взима две числа от стандартния вход и извежда *true* ако първото е по - малко от второто - и *false* в противен случай. - -4.Напишете програма, която приема от входа две двойки реални числа, отговарящи на две точки в равнината. - Да се отпечата растоянието между точките закръглено до 2-рия знак след десетичната запетая. - **Потърсете математическата формула в интернет ако не я знаете!** - -БОНУС:Напишете програма която приема номер на кредитна карта(16 цифри). - Програмата да изведе същият този номер, но със скрити първите 12 цифри (XXXXXXXXXXXX1234). -БОНУС:**Направете го без да записвате X-ове променлива и без да правите ```cout<<"XXXXXXXXXXXX"``` :)** diff --git a/pract_SI/pract. 01/task1.cpp b/pract_SI/pract. 01/task1.cpp deleted file mode 100644 index 54a1902..0000000 --- a/pract_SI/pract. 01/task1.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - string name; - cout << "What is your name?\n"; - cin >> name; - cout << "Hello, " << name << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 01/task2.cpp b/pract_SI/pract. 01/task2.cpp deleted file mode 100644 index 554653d..0000000 --- a/pract_SI/pract. 01/task2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -using namespace std; -int main() -{ - double x, y; - - cout << "First side: "; - cin >> x; - - cout << "Second side: "; - cin >> y; - - cout << "Parameter: " << 2 * (x + y) << endl; - cout << "Area: " << x * y << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 01/task3.cpp b/pract_SI/pract. 01/task3.cpp deleted file mode 100644 index 830348b..0000000 --- a/pract_SI/pract. 01/task3.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -using namespace std; -int main() -{ - double a, b; - - cout << "First number: "; - cin >> a; - - cout << "Second number: "; - cin >> b; - - cout << boolalpha << (a < b) << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 01/task4.cpp b/pract_SI/pract. 01/task4.cpp deleted file mode 100644 index b4829b4..0000000 --- a/pract_SI/pract. 01/task4.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - double x1, y1, x2, y2; - - cout << "x1: "; - cin >> x1; - - cout << "y1: "; - cin >> y1; - - cout << "x2: "; - cin >> x2; - - cout << "y2: "; - cin >> y2; - - cout << round(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) * 100) / 100 << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 01/task5.cpp b/pract_SI/pract. 01/task5.cpp deleted file mode 100644 index 576bf2e..0000000 --- a/pract_SI/pract. 01/task5.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -using namespace std; -int main() -{ - string card_number;; - - cout << "Card number: "; - cin >> card_number; - - cout << "Hidden card number: " << setfill('X') << setw(13) - << card_number[12] << card_number[13] << card_number[14] << card_number[15] << endl; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/Tasks_2.txt b/pract_SI/pract. 02/Tasks_2.txt deleted file mode 100644 index a419241..0000000 --- a/pract_SI/pract. 02/Tasks_2.txt +++ /dev/null @@ -1,37 +0,0 @@ -#Никола Светославов - task2 - -## Задачи - -1. Напишете програма,която проверява дали въведена от потребителя година е високосна. - **Проверете сами кои години се считат за високосни** - -2. Напишете програма, която приема един символ от входа и проверява дали: - - * този символ е буква от латинската азбука; - * ако да, дали тази буква е гласна или съгласна. - - **Програмата да работи както за малки, така и за главни букви** - -3. Напишете програма, която приема две **различни** числа и казва кое е по голямо. - **Използвайте тернарен оператор** - -4. Напишете програма, която приема от входа три числа - страни на триъгълник. - Програмата да проверява дали това е валиден триъгълник. - -5. Напишете програма, която намира корените на квадратно уравнение. - За целта потребителя да въведе коефицентите на уравнението - *a*, *b*, и *c* - при уравнение с вид *a \* x^2 + b \* x + c = 0*. - -6. Напишете прост калкулатор, който поддържа операциите +, -, *, / на две реални числа. - **Внимавайте с делението на 0** - -7. Да се състави програма, чрез която се въвежда 4-цифренo естествено число от интервала [1000.. 9999]. - От това число се формират 2 нови 2-цифрени числа. Първото число се формира от 1-та и 4-та цифра на въведеното - число. Второто число се формира от 2-рa - 3-та цифра на въведеното число.На екрана да се изведе дали - 1-то ново число e по-малко <, равно = или по-голямо от 2-то число. - Използвайте проверка на логическо условие - оператор if. - //Задачата е взета от [тук](http://1001zadachi.com/оператор_if_сравняване_числа.html). - - **Пример: 3332 Изход: less (32<33) - **Пример: 1144 Изход: equal (14=14) - **Пример: 9875 Изход: greater (95>87) diff --git a/pract_SI/pract. 02/task1.cpp b/pract_SI/pract. 02/task1.cpp deleted file mode 100644 index 3a60fad..0000000 --- a/pract_SI/pract. 02/task1.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -using namespace std; -int main() -{ - int year; - - cout << "Enter an year to check: "; - cin >> year; - - cout << year << " is"; - - if (!(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) - { - cout << " not"; - } - - cout << " leap!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task2.cpp b/pract_SI/pract. 02/task2.cpp deleted file mode 100644 index a1ddcf8..0000000 --- a/pract_SI/pract. 02/task2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -using namespace std; -int main() -{ - char inputCharacter; - - cout << "Enter a character to test: "; - cin >> inputCharacter; - - cout << inputCharacter << " is "; - if (inputCharacter == 'a' || inputCharacter == 'e' || inputCharacter == 'i' || inputCharacter == 'o' || inputCharacter == 'u' || - inputCharacter == 'A' || inputCharacter == 'E' || inputCharacter == 'I' || inputCharacter == 'O' || inputCharacter == 'U') - { - cout << "a vowel!\n"; - } - else - { - if ((inputCharacter >= 'a' && inputCharacter <= 'z') || (inputCharacter >= 'A' && inputCharacter <= 'Z')) - { - cout << "a consonant!\n"; - } - else - { - cout << "is not a letter from the English alphabet!\n"; - } - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task3 - no EPSILON.cpp b/pract_SI/pract. 02/task3 - no EPSILON.cpp deleted file mode 100644 index 6c9f832..0000000 --- a/pract_SI/pract. 02/task3 - no EPSILON.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - double x, y; - - cout << "Enter the first number: "; - cin >> x; - - cout << "Enter the second number: "; - cin >> y; - - if (fabs(x - y) < 0.000001) - { - cout << "Numbers must be different!\n"; - return 1; - } - - cout << (x < y ? y : x) << " is the greater number!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task3 - with EPSILON.cpp b/pract_SI/pract. 02/task3 - with EPSILON.cpp deleted file mode 100644 index dcd5f88..0000000 --- a/pract_SI/pract. 02/task3 - with EPSILON.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -using namespace std; - -int main() -{ - double num1, num2; - - cout << "Enter the first number: "; - cin >> num1; - - cout << "Enter the second number: "; - cin >> num2; - - if (fabs(num1 - num2) <= DBL_EPSILON * fabs(num1)) - { - cout << "Numbers must be different!\n"; - return 1; - } - - cout << (num1 > num2 ? "First" : "Second") << " is the greater number!\n"; - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task4.cpp b/pract_SI/pract. 02/task4.cpp deleted file mode 100644 index acb471c..0000000 --- a/pract_SI/pract. 02/task4.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -using namespace std; -int main() -{ - double a, b, c; - - cout << "First side: "; - cin >> a; - - cout << "Second side: "; - cin >> b; - - cout << "Third side: "; - cin >> c; - - if ((a + b > c) && (a + c > b) && (b + c > a)) - { - cout << "Triangle is valid.\n"; - } - else - { - cout << "Triangle is not valid.\n"; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task5.cpp b/pract_SI/pract. 02/task5.cpp deleted file mode 100644 index 419d6d4..0000000 --- a/pract_SI/pract. 02/task5.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -using namespace std; -int main() -{ - double a, b, c; - double root1, root2, imaginary; - double discriminant; - - cout << "Finding the root of the equation a * x^2 + b * x + c = 0\n"; - - cout << "Enter the value of a: "; - cin >> a; - - if (a < 0.00000001) - { - cout << "If a is 0, then this is not a quadratic equation!\n"; - return 1; - } - - cout << "Enter the value of b: "; - cin >> b; - - cout << "Enter the value of c: "; - cin >> c; - - discriminant = (b * b) - (4 * a * c); - - if (discriminant > 0) - { - root1 = (-b + sqrt(discriminant)) / (2 * a); - root2 = (-b - sqrt(discriminant)) / (2 * a); - - cout << "Two distinct and real roots exist: " << root1 << " and " << root2 << endl; - } - else if (discriminant == 0) - { - root1 = root2 = -b / (2 * a); - - cout << "Two equal and real roots exist: " << root1 << " and " << root2 << endl; - } - else if (discriminant < 0) - { - root1 = root2 = -b / (2 * a); - imaginary = sqrt(-discriminant) / (2 * a); - - cout << "Two distinct complex roots exist: " << root1 << "+" << imaginary << "i and " << root2 << "-" << imaginary << "i\n"; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task6.cpp b/pract_SI/pract. 02/task6.cpp deleted file mode 100644 index a7484b2..0000000 --- a/pract_SI/pract. 02/task6.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -using namespace std; -int main() -{ - double a, b; - char operation; - - cout << "Enter the first number: "; - cin >> a; - - cout << "Enter the second number: "; - cin >> b; - - cout << "Choose operation: +, -, / or *: "; - cin >> operation; - - switch (operation) - { - case '+': - cout << "Result: " << a + b << endl; - break; - case '-': - cout << "Result: " << a - b << endl; - break; - case '*': - cout << "Result: " << a * b << endl; - break; - case '/': - if (b < 0.0000001) - { - cout << "You can not divide by zero!\n"; - return 1; - } - cout << "Result: " << a / b << endl; - break; - default: - cout << "Invalid operation!\n"; - break; - } - - return 0; -} \ No newline at end of file diff --git a/pract_SI/pract. 02/task7.cpp b/pract_SI/pract. 02/task7.cpp deleted file mode 100644 index 3c22a83..0000000 --- a/pract_SI/pract. 02/task7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -using namespace std; -int main() -{ - // you can use int as well, but do you really need something as big as int? - short number; - unsigned char digit1, digit2, digit3, digit4, number1, number2; - - cout << "Enter a 4-digit number: "; - cin >> number; - - if (number < 1000 || number > 10000) - { - cout << "The input must be a 4-digit number!\n"; - return 1; - } - - digit1 = number / 1000; - digit2 = number / 100 % 10; - digit3 = number / 10 % 10; - digit4 = number % 10; - - number1 = digit1 * 10 + digit4; - number2 = digit2 * 10 + digit3; - - if (number1 < number2) - { - cout << "less (" << (int)number1 << " < " << (int)number2 << ")\n"; - } - else - { - if (number1 == number2) - { - cout << "equal (" << (int)number1 << " = " << (int)number2 << ")\n"; - } - else - { - cout << "greater (" << (int)number1 << " > " << (int)number2 << ")\n"; - } - } - - - return 0; -} \ No newline at end of file -- cgit v1.3.1-23-gd82d From 45167f8e4f3df0ca9ad4444272c1b8acf9a08f2c Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Thu, 28 Oct 2021 17:38:59 +0300 Subject: Rename change --- pract_SI/Pract. 01/Solutions/task1.cpp | 12 ++ pract_SI/Pract. 01/Solutions/task2.cpp | 17 +++ pract_SI/Pract. 01/Solutions/task3.cpp | 16 +++ pract_SI/Pract. 01/Solutions/task4.cpp | 23 ++++ pract_SI/Pract. 01/Solutions/task5.cpp | 16 +++ pract_SI/Pract. 01/Tasks_1.txt | 20 ++++ pract_SI/Pract. 02/Solutions/task1.cpp | 20 ++++ pract_SI/Pract. 02/Solutions/task2.cpp | 29 +++++ .../Pract. 02/Solutions/task3 - no EPSILON.cpp | 23 ++++ .../Pract. 02/Solutions/task3 - with EPSILON.cpp | 24 ++++ pract_SI/Pract. 02/Solutions/task4.cpp | 26 ++++ pract_SI/Pract. 02/Solutions/task5.cpp | 51 ++++++++ pract_SI/Pract. 02/Solutions/task6.cpp | 42 +++++++ pract_SI/Pract. 02/Solutions/task7.cpp | 44 +++++++ pract_SI/Pract. 02/Tasks_2.txt | 37 ++++++ pract_SI/Pract. 03/Solutions/task1.cpp | 19 +++ pract_SI/Pract. 03/Solutions/task2.cpp | 17 +++ pract_SI/Pract. 03/Solutions/task3.cpp | 22 ++++ pract_SI/Pract. 03/Solutions/task4.cpp | 21 ++++ pract_SI/Pract. 03/Solutions/task5.cpp | 41 +++++++ pract_SI/Pract. 03/Solutions/task6.cpp | 18 +++ pract_SI/Pract. 03/Solutions/task7.cpp | 30 +++++ pract_SI/Pract. 03/Solutions/task8.cpp | 41 +++++++ pract_SI/Pract. 03/Solutions/task9.cpp | 59 ++++++++++ pract_SI/Pract. 03/Startup_tasks.txt | 7 ++ pract_SI/Pract. 03/Tasks3.txt | 131 +++++++++++++++++++++ 26 files changed, 806 insertions(+) create mode 100644 pract_SI/Pract. 01/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task2.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task3.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 01/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 01/Tasks_1.txt create mode 100644 pract_SI/Pract. 02/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task2.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task6.cpp create mode 100644 pract_SI/Pract. 02/Solutions/task7.cpp create mode 100644 pract_SI/Pract. 02/Tasks_2.txt create mode 100644 pract_SI/Pract. 03/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task2.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task3.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task6.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task7.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task8.cpp create mode 100644 pract_SI/Pract. 03/Solutions/task9.cpp create mode 100644 pract_SI/Pract. 03/Startup_tasks.txt create mode 100644 pract_SI/Pract. 03/Tasks3.txt (limited to 'pract_SI') diff --git a/pract_SI/Pract. 01/Solutions/task1.cpp b/pract_SI/Pract. 01/Solutions/task1.cpp new file mode 100644 index 0000000..54a1902 --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task1.cpp @@ -0,0 +1,12 @@ +#include +#include +using namespace std; +int main() +{ + string name; + cout << "What is your name?\n"; + cin >> name; + cout << "Hello, " << name << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task2.cpp b/pract_SI/Pract. 01/Solutions/task2.cpp new file mode 100644 index 0000000..554653d --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task2.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +int main() +{ + double x, y; + + cout << "First side: "; + cin >> x; + + cout << "Second side: "; + cin >> y; + + cout << "Parameter: " << 2 * (x + y) << endl; + cout << "Area: " << x * y << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task3.cpp b/pract_SI/Pract. 01/Solutions/task3.cpp new file mode 100644 index 0000000..830348b --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task3.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +int main() +{ + double a, b; + + cout << "First number: "; + cin >> a; + + cout << "Second number: "; + cin >> b; + + cout << boolalpha << (a < b) << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task4.cpp b/pract_SI/Pract. 01/Solutions/task4.cpp new file mode 100644 index 0000000..b4829b4 --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task4.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +int main() +{ + double x1, y1, x2, y2; + + cout << "x1: "; + cin >> x1; + + cout << "y1: "; + cin >> y1; + + cout << "x2: "; + cin >> x2; + + cout << "y2: "; + cin >> y2; + + cout << round(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) * 100) / 100 << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Solutions/task5.cpp b/pract_SI/Pract. 01/Solutions/task5.cpp new file mode 100644 index 0000000..931178d --- /dev/null +++ b/pract_SI/Pract. 01/Solutions/task5.cpp @@ -0,0 +1,16 @@ +#include +#include +#include +using namespace std; +int main() +{ + string card_number; + + cout << "Card number: "; + cin >> card_number; + + cout << "Hidden card number: " << setfill('X') << setw(13) + << card_number[12] << card_number[13] << card_number[14] << card_number[15] << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 01/Tasks_1.txt b/pract_SI/Pract. 01/Tasks_1.txt new file mode 100644 index 0000000..bb7ee2d --- /dev/null +++ b/pract_SI/Pract. 01/Tasks_1.txt @@ -0,0 +1,20 @@ +Никола Светославов - task1 + +## Задачи +1.Напишете програма, която пита потребителя за името му, след което отпечатва "Hello, <име>" + +2.Напишете програма, която подканя потребителя да въведе дължините на двете страни на правоъгълник + **като му извежда съобщение, например "Please enter the length of the first side:"** + Програмата да изведе периметърът и лицето на този правоъгълник. + **Страните може да не са цели числа!** + +3.Напишете програма, която взима две числа от стандартния вход и извежда *true* ако първото е по - малко от второто + и *false* в противен случай. + +4.Напишете програма, която приема от входа две двойки реални числа, отговарящи на две точки в равнината. + Да се отпечата растоянието между точките закръглено до 2-рия знак след десетичната запетая. + **Потърсете математическата формула в интернет ако не я знаете!** + +БОНУС:Напишете програма която приема номер на кредитна карта(16 цифри). + Програмата да изведе същият този номер, но със скрити първите 12 цифри (XXXXXXXXXXXX1234). +БОНУС:**Направете го без да записвате X-ове променлива и без да правите ```cout<<"XXXXXXXXXXXX"``` :)** diff --git a/pract_SI/Pract. 02/Solutions/task1.cpp b/pract_SI/Pract. 02/Solutions/task1.cpp new file mode 100644 index 0000000..3a60fad --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task1.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +int main() +{ + int year; + + cout << "Enter an year to check: "; + cin >> year; + + cout << year << " is"; + + if (!(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) + { + cout << " not"; + } + + cout << " leap!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task2.cpp b/pract_SI/Pract. 02/Solutions/task2.cpp new file mode 100644 index 0000000..a1ddcf8 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task2.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; +int main() +{ + char inputCharacter; + + cout << "Enter a character to test: "; + cin >> inputCharacter; + + cout << inputCharacter << " is "; + if (inputCharacter == 'a' || inputCharacter == 'e' || inputCharacter == 'i' || inputCharacter == 'o' || inputCharacter == 'u' || + inputCharacter == 'A' || inputCharacter == 'E' || inputCharacter == 'I' || inputCharacter == 'O' || inputCharacter == 'U') + { + cout << "a vowel!\n"; + } + else + { + if ((inputCharacter >= 'a' && inputCharacter <= 'z') || (inputCharacter >= 'A' && inputCharacter <= 'Z')) + { + cout << "a consonant!\n"; + } + else + { + cout << "is not a letter from the English alphabet!\n"; + } + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp b/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp new file mode 100644 index 0000000..6c9f832 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task3 - no EPSILON.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +int main() +{ + double x, y; + + cout << "Enter the first number: "; + cin >> x; + + cout << "Enter the second number: "; + cin >> y; + + if (fabs(x - y) < 0.000001) + { + cout << "Numbers must be different!\n"; + return 1; + } + + cout << (x < y ? y : x) << " is the greater number!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp b/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp new file mode 100644 index 0000000..dcd5f88 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task3 - with EPSILON.cpp @@ -0,0 +1,24 @@ +#include +#include +using namespace std; + +int main() +{ + double num1, num2; + + cout << "Enter the first number: "; + cin >> num1; + + cout << "Enter the second number: "; + cin >> num2; + + if (fabs(num1 - num2) <= DBL_EPSILON * fabs(num1)) + { + cout << "Numbers must be different!\n"; + return 1; + } + + cout << (num1 > num2 ? "First" : "Second") << " is the greater number!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task4.cpp b/pract_SI/Pract. 02/Solutions/task4.cpp new file mode 100644 index 0000000..acb471c --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task4.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; +int main() +{ + double a, b, c; + + cout << "First side: "; + cin >> a; + + cout << "Second side: "; + cin >> b; + + cout << "Third side: "; + cin >> c; + + if ((a + b > c) && (a + c > b) && (b + c > a)) + { + cout << "Triangle is valid.\n"; + } + else + { + cout << "Triangle is not valid.\n"; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task5.cpp b/pract_SI/Pract. 02/Solutions/task5.cpp new file mode 100644 index 0000000..419d6d4 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task5.cpp @@ -0,0 +1,51 @@ +#include +#include +using namespace std; +int main() +{ + double a, b, c; + double root1, root2, imaginary; + double discriminant; + + cout << "Finding the root of the equation a * x^2 + b * x + c = 0\n"; + + cout << "Enter the value of a: "; + cin >> a; + + if (a < 0.00000001) + { + cout << "If a is 0, then this is not a quadratic equation!\n"; + return 1; + } + + cout << "Enter the value of b: "; + cin >> b; + + cout << "Enter the value of c: "; + cin >> c; + + discriminant = (b * b) - (4 * a * c); + + if (discriminant > 0) + { + root1 = (-b + sqrt(discriminant)) / (2 * a); + root2 = (-b - sqrt(discriminant)) / (2 * a); + + cout << "Two distinct and real roots exist: " << root1 << " and " << root2 << endl; + } + else if (discriminant == 0) + { + root1 = root2 = -b / (2 * a); + + cout << "Two equal and real roots exist: " << root1 << " and " << root2 << endl; + } + else if (discriminant < 0) + { + root1 = root2 = -b / (2 * a); + imaginary = sqrt(-discriminant) / (2 * a); + + cout << "Two distinct complex roots exist: " << root1 << "+" << imaginary << "i and " << root2 << "-" << imaginary << "i\n"; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task6.cpp b/pract_SI/Pract. 02/Solutions/task6.cpp new file mode 100644 index 0000000..a7484b2 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task6.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; +int main() +{ + double a, b; + char operation; + + cout << "Enter the first number: "; + cin >> a; + + cout << "Enter the second number: "; + cin >> b; + + cout << "Choose operation: +, -, / or *: "; + cin >> operation; + + switch (operation) + { + case '+': + cout << "Result: " << a + b << endl; + break; + case '-': + cout << "Result: " << a - b << endl; + break; + case '*': + cout << "Result: " << a * b << endl; + break; + case '/': + if (b < 0.0000001) + { + cout << "You can not divide by zero!\n"; + return 1; + } + cout << "Result: " << a / b << endl; + break; + default: + cout << "Invalid operation!\n"; + break; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Solutions/task7.cpp b/pract_SI/Pract. 02/Solutions/task7.cpp new file mode 100644 index 0000000..3c22a83 --- /dev/null +++ b/pract_SI/Pract. 02/Solutions/task7.cpp @@ -0,0 +1,44 @@ +#include +using namespace std; +int main() +{ + // you can use int as well, but do you really need something as big as int? + short number; + unsigned char digit1, digit2, digit3, digit4, number1, number2; + + cout << "Enter a 4-digit number: "; + cin >> number; + + if (number < 1000 || number > 10000) + { + cout << "The input must be a 4-digit number!\n"; + return 1; + } + + digit1 = number / 1000; + digit2 = number / 100 % 10; + digit3 = number / 10 % 10; + digit4 = number % 10; + + number1 = digit1 * 10 + digit4; + number2 = digit2 * 10 + digit3; + + if (number1 < number2) + { + cout << "less (" << (int)number1 << " < " << (int)number2 << ")\n"; + } + else + { + if (number1 == number2) + { + cout << "equal (" << (int)number1 << " = " << (int)number2 << ")\n"; + } + else + { + cout << "greater (" << (int)number1 << " > " << (int)number2 << ")\n"; + } + } + + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 02/Tasks_2.txt b/pract_SI/Pract. 02/Tasks_2.txt new file mode 100644 index 0000000..a419241 --- /dev/null +++ b/pract_SI/Pract. 02/Tasks_2.txt @@ -0,0 +1,37 @@ +#Никола Светославов - task2 + +## Задачи + +1. Напишете програма,която проверява дали въведена от потребителя година е високосна. + **Проверете сами кои години се считат за високосни** + +2. Напишете програма, която приема един символ от входа и проверява дали: + + * този символ е буква от латинската азбука; + * ако да, дали тази буква е гласна или съгласна. + + **Програмата да работи както за малки, така и за главни букви** + +3. Напишете програма, която приема две **различни** числа и казва кое е по голямо. + **Използвайте тернарен оператор** + +4. Напишете програма, която приема от входа три числа - страни на триъгълник. + Програмата да проверява дали това е валиден триъгълник. + +5. Напишете програма, която намира корените на квадратно уравнение. + За целта потребителя да въведе коефицентите на уравнението - *a*, *b*, и *c* + при уравнение с вид *a \* x^2 + b \* x + c = 0*. + +6. Напишете прост калкулатор, който поддържа операциите +, -, *, / на две реални числа. + **Внимавайте с делението на 0** + +7. Да се състави програма, чрез която се въвежда 4-цифренo естествено число от интервала [1000.. 9999]. + От това число се формират 2 нови 2-цифрени числа. Първото число се формира от 1-та и 4-та цифра на въведеното + число. Второто число се формира от 2-рa - 3-та цифра на въведеното число.На екрана да се изведе дали + 1-то ново число e по-малко <, равно = или по-голямо от 2-то число. + Използвайте проверка на логическо условие - оператор if. + //Задачата е взета от [тук](http://1001zadachi.com/оператор_if_сравняване_числа.html). + + **Пример: 3332 Изход: less (32<33) + **Пример: 1144 Изход: equal (14=14) + **Пример: 9875 Изход: greater (95>87) diff --git a/pract_SI/Pract. 03/Solutions/task1.cpp b/pract_SI/Pract. 03/Solutions/task1.cpp new file mode 100644 index 0000000..ae955a8 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task1.cpp @@ -0,0 +1,19 @@ +#include "pch.h" +#include + +using namespace std; + +int main() +{ + unsigned long long number; + cin >> number; + + for (int i = 1; i <= number; i++) + { + for (int j = 1; j <= i; j++) + cout << j; + cout << endl; + } + + return 0; +} diff --git a/pract_SI/Pract. 03/Solutions/task2.cpp b/pract_SI/Pract. 03/Solutions/task2.cpp new file mode 100644 index 0000000..b3e970d --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task2.cpp @@ -0,0 +1,17 @@ +#include + +using namespace std; + +int main() +{ + unsigned long long number; + cin >> number; + + for (unsigned long long x = 1, y = number; x < number; x++) + { + cout << "x = " << x << " " + << "y = " << --y << endl; + } + + return 0; +} diff --git a/pract_SI/Pract. 03/Solutions/task3.cpp b/pract_SI/Pract. 03/Solutions/task3.cpp new file mode 100644 index 0000000..a6a6362 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task3.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; +int main() +{ + unsigned long long oldNumber, newNumber; + + cout << "Enter a positive number: "; + cin >> oldNumber; + + oldNumber *= oldNumber; + newNumber = 0; + + while (oldNumber != 0) + { + newNumber = newNumber * 10 + oldNumber % 10; + oldNumber /= 10; + } + + cout << newNumber << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task4.cpp b/pract_SI/Pract. 03/Solutions/task4.cpp new file mode 100644 index 0000000..622b8a1 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task4.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; +int main() +{ + unsigned int m, n; + cout << "Number of rows: "; + cin >> m; + cout << "Number of columns: "; + cin >> n; + + for (unsigned int i = 1; i <= m * n; i++) + { + cout << i << " "; + if (i % n == 0) + { + cout << endl; + } + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task5.cpp b/pract_SI/Pract. 03/Solutions/task5.cpp new file mode 100644 index 0000000..d6ac57c --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task5.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +int main() +{ + unsigned short number, guess; + unsigned int counter = 0; + + cout << "Enter a number between 0 and 100: "; + cin >> number; + if (number < 0 || number > 100) + { + cout << "Invalid input!\n"; + return 1; + } + + do + { + ++counter; + + cout << "Guess " << counter << ": "; + cin >> guess; + if (guess < 0 || guess > 100) + { + cout << "Invalid input!\n"; + return 2; + } + + if (guess < number) + { + cout << "The number you are looking for is greater than your guess!\n"; + } + else if (guess > number) + { + cout << "The number you are looking for is less than your guess!\n"; + } + } while (guess != number); + + cout << "You found the number in " << counter << " attempt(s)!\n"; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task6.cpp b/pract_SI/Pract. 03/Solutions/task6.cpp new file mode 100644 index 0000000..8d0beac --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task6.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; +int main() +{ + unsigned int number = 0, input = 1; + + while(input != 0) + { + cout << "Enter a positive number: "; + cin >> input; + + number ^= input; + } + + cout << "The single number is " << number << endl; + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task7.cpp b/pract_SI/Pract. 03/Solutions/task7.cpp new file mode 100644 index 0000000..aa9194b --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task7.cpp @@ -0,0 +1,30 @@ +#include +#define LIMIT 5 +#define SEPARATOR " " + +using namespace std; + +//const short LIMIT = 5; +//const char SEPARATOR = ' '; + + +int main() +{ + unsigned long long N; + cin >> N; + + if (N < LIMIT) + return -1; + + for (int c = 1; c <= N; c++) { + for (int b = 1; b < c; b++) { + for (int a = 1; a < b; a++) { + if ((a * a) + (b * b) == (c * c)) { + cout << a << SEPARATOR << b << SEPARATOR << c << endl; + } + } + } + } + + return 0; +} diff --git a/pract_SI/Pract. 03/Solutions/task8.cpp b/pract_SI/Pract. 03/Solutions/task8.cpp new file mode 100644 index 0000000..3f32ebf --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task8.cpp @@ -0,0 +1,41 @@ +#include + +using namespace std; + +const short LOWERLIMIT = 2; +const short UPPERLIMIT = 9; +const char SEPARATOR = ' '; + +int main() +{ + short N; + char S; + cin >> N >> S; + + if (N < LOWERLIMIT || N > UPPERLIMIT) + return -1; //end program + + for (int i = 1; i <= N; i++) + { + for (int j = N - i; j > 0; j--) + cout << SEPARATOR; + + for (int k = 1; k < 2 * i; k++) + cout << S; + + cout << endl; + } + + for (int i = 1; i < N; i++) + { + for (int j = 1; j <= i; j++) + cout << SEPARATOR; + + for (int k = 1; k < 2 * (N - i); k++) + cout << S; + + cout << endl; + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Solutions/task9.cpp b/pract_SI/Pract. 03/Solutions/task9.cpp new file mode 100644 index 0000000..9f1f054 --- /dev/null +++ b/pract_SI/Pract. 03/Solutions/task9.cpp @@ -0,0 +1,59 @@ +#include + +int main() { + + // по-нататък ще учим как се вкарват сложни данни, затова сега ще ги hardcode-нем в main-а + + int hoursOnesStart = 2, minutesTensStart = 5, secondsOnesStart = 6; + int hoursOnesFinal = 1, minutesTensFinal = 0, secondsOnesFinal = 2; + int hoursDelta = 10, minutesDelta = 19, secondsDelta = 26; + + for (size_t hoursTensStart = 0; hoursTensStart <= 1; ++hoursTensStart) + { + for (size_t minutesOnesStart = 0; minutesOnesStart <= 9; ++minutesOnesStart) + { + for (size_t secondsTensStart = 0; secondsTensStart <= 5; secondsTensStart++) + { + int hoursTemp = hoursTensStart * 10 + hoursOnesStart; + int minutesTemp = minutesTensStart * 10 + minutesOnesStart; + int secondsTemp = secondsTensStart * 10 + secondsOnesStart; + + secondsTemp += secondsDelta; + if (secondsTemp >= 60) { + minutesTemp += secondsTemp / 60; + secondsTemp %= 60; + } + + minutesTemp += minutesDelta; + if (minutesTemp >= 60) { + hoursTemp += minutesTemp / 60; + minutesTemp %= 60; + } + + hoursTemp += hoursDelta; + if (hoursTemp > 12) { + hoursTemp %= 12; + } + + bool hoursOnesMatch = hoursTemp % 10 == hoursOnesFinal, + minutesTensMatch = minutesTemp / 10 == minutesTensFinal, + secondsOnesMatch = secondsTemp % 10 == secondsOnesFinal; + + if (hoursOnesMatch && minutesTensMatch && secondsOnesMatch) { + int hoursTensFinal = hoursTemp / 10, + minutesOnesFinal = minutesTemp % 10, + secondsTensFinal = secondsTemp / 10; + + std::cout << hoursTensStart << hoursOnesStart << ':' + << minutesTensStart << minutesOnesStart << ':' + << secondsTensStart << secondsOnesStart << ' ' + << hoursTensFinal << hoursOnesFinal << ':' + << minutesTensFinal << minutesOnesFinal << ':' + << secondsTensFinal << secondsOnesFinal << '\n'; + } + } + } + } + + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Startup_tasks.txt b/pract_SI/Pract. 03/Startup_tasks.txt new file mode 100644 index 0000000..8ee6d58 --- /dev/null +++ b/pract_SI/Pract. 03/Startup_tasks.txt @@ -0,0 +1,7 @@ +1.Напишете програма , която приема като вход N лева.Да се отпечата как бихме разпределили сумата на банкноти, +така че да имаме минимален брой банкноти. (Да не се използват условни оператори и цикли) +Пояснение: Нека да приемем, че имаме банкноти с 1лв и 2лв. + +2.Напишете програма, която приема като вход цяло положително число V, което ще отговаря на скорост. +Програмата да отпечатва колко е глобата от КАТ, а ако няма глоба следното съобщение "No speedticket". +(https://stamatovandpartners.com/elektronen-fish-za-previshena-skorost/) \ No newline at end of file diff --git a/pract_SI/Pract. 03/Tasks3.txt b/pract_SI/Pract. 03/Tasks3.txt new file mode 100644 index 0000000..64c5c4c --- /dev/null +++ b/pract_SI/Pract. 03/Tasks3.txt @@ -0,0 +1,131 @@ +#Никола Светославов - task3 + +## Задачи + +1.Да се напише програма, която приема естествено число n и изписва стълба от 1 до n + +Пример +Вход: +5 +Изход: +1 +12 +123 +1234 +12345 + +2.Да се състави програма, която по въведено естествено число n да изведе всички естествени решения на уравнението x + y = n. + +Пример +Вход: +4 +Изход: +x = 1 y = 3 +x = 2 y = 2 +x = 3 y = 1 + + +3.Напишете програма, която по въведено цяло положително число, извежда квадратът на това число, но в обратен ред, като водещите нули се игнорират. + +Пример +Вход: +10 +Изход: +1 + +Вход: +25 +Изход: +526 + +4.Напишете програма, която приема от потребителя две цели положителни числа - *m* и *n*. + Програмата да отпечата числатаот 1 до m*n, като на всеки ред има по *n* числа (тоест ще отпечатате *m* реда). + Печатайте числата по редове: + +Пример +Вход: +2 3 +Изход: +1 2 3 +4 5 6 + +5.Напишете проста игра, в която първо се въвежда цяло число в интервала [0;100] и в последствие се въвеждат цели числа + (предположения), като за всяко се казва дали е по - малко или по - голямо от първоначално ваведеното. + Tова продължава до въвеждане на число, равно на първоначалното. Програмата да отпечата и броят направени предположения. + +6.Напишете програма, която иска от потребителя поредица от цели числа по - големи от 0. + Въвеждането приключва с въвеждане на 0. Гарантирано е, че всяко от числата е въведено **точно два пъти** освен едно, + което е въведено **точно веднъж**. Програмата да изведе кое е това число. + +7.Да се състави програма, която по въведено естествено число N намира и отпечатва всички тройки естествени числа a, b и c, + не по-големи от N, които могат да бъдат страни на правоъгълен триъгълник. + +Пример +Вход: +11 +Изход +3 4 5 +6 8 10 + +8.Напишете програма, която иска от потребителя вход цифра N[2;9] и символ S.Програмата да извежда фигура съставена от символа във вид на ромб, както е показано на примерите. + +Пример +Вход: +5 * +Изход + * + *** + ***** + ******* +********* + ******* + ***** + *** + * + +*Бонус* +Задача ЕЛЕКТРОНЕН ЧАСОВНИК +В големия нов МОЛ в града на програмистите се повредили част от цифрите на електронния часовник. +Повредени били първата цифра от числото, което показва часовете, втората цифра на числото, което показва минутите и първата цифра на числото, което показва секундите. +Вместо тях на екрана се появявал знака *. +Когато Коко и приятелите му ходели на кино, те не успявали да преценят точно колко е часа. +Все пак, момчетата си създали система за изчисление, която приблизително точно им показвало времето. +Те успявали да предвидят колко е показвал часовника в началото и края на филма, в случай че знаят точно колко време е минало. +Срещу името на всеки филм на входа на киното е дадено неговото времетраене в часове, минути и секунди. +Пресмятанията доста затрудняват момчетата и затова на тях ще им е по-удобно това да се прави с компютърна програма. +Те не разбират много от програмиране и затова вие трябва да напишете програма clock, която помага на Коко и приятелите му. + +Вход: +На първия ред на стандартния вход е записана последователност от цифри и знака *, която показва какво се вижда на екрана на часовника в началото на филма. +На втория ред е записана подобна последователност за показанието на часовника в края на филма. +На третия ред се въвежда продължителността на филма в часове, минути и секунди. +Часовникът е настроен така, че показва времето по 12-часова скала, а не по 24-часова. + +Изход: +На стандартния изход изведете всички възможни показания на часовника за началото и края на филма. +Всяка двойка с начален и краен час се извежда на един ред, като първо се извежда началното показание във формат hh:mm:ss, и след един интервал крайното показание в същия формат. +Ако такива показания на часовника не са възможни, да се изведе “Impossible”. + +Ограничения: +Продължителността на филма е не по-голяма 12 часа. + +Примери: + +Вход: +*25**6 +*10**2 +10 19 26 +Изход: +02:50:06 01:09:32 +02:50:16 01:09:42 +02:50:26 01:09:52 +12:50:06 11:09:32 +12:50:16 11:09:42 +12:50:26 11:09:52 + +Вход: +*95**6 +*21**2 +4 12 6 +Изход: +Impossible -- cgit v1.3.1-23-gd82d From a6e73ce736a7c0e7decb30c9ee63eeca3d14e735 Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Thu, 28 Oct 2021 18:11:24 +0300 Subject: Added Startup_tasks solutions --- .../Startup_tasks - Solutions/task1_solution1.cpp | 35 +++++++++++++++++++++ .../Startup_tasks - Solutions/task1_solution2.cpp | 35 +++++++++++++++++++++ .../Pract. 03/Startup_tasks - Solutions/task2.cpp | 36 ++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution1.cpp create mode 100644 pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution2.cpp create mode 100644 pract_SI/Pract. 03/Startup_tasks - Solutions/task2.cpp (limited to 'pract_SI') diff --git a/pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution1.cpp b/pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution1.cpp new file mode 100644 index 0000000..988d53c --- /dev/null +++ b/pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution1.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int main() +{ + int n, initialSum; + cin >> n; + initialSum = n; + + int Hundred_Dollar_Bill = 0; + int Fifty_Dollar_Bill = 0; + int Twenty_Dollar_Bill = 0; + int Ten_Dollar_Bill = 0; + int Five_Dollar_Bill = 0; + int Two_Dollar_Bill = 0; + int One_Dollar_Bill = 0; + + Hundred_Dollar_Bill = n / 100; + n %= 100; + Fifty_Dollar_Bill = n / 50; + n %= 50; + Twenty_Dollar_Bill = n / 20; + n %= 20; + Ten_Dollar_Bill = n / 10; + n %= 10; + Five_Dollar_Bill = n / 5; + n %= 5; + Two_Dollar_Bill = n / 2; + n %= 2; + One_Dollar_Bill = n; + + cout << initialSum << " = " << Hundred_Dollar_Bill << "*100 + " << Fifty_Dollar_Bill << "*50 + " << Twenty_Dollar_Bill << "*20 + " << Ten_Dollar_Bill << "*10 + " << + Five_Dollar_Bill << "*5 + " << Two_Dollar_Bill << "*2 + " << One_Dollar_Bill << "*1" << endl; +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution2.cpp b/pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution2.cpp new file mode 100644 index 0000000..f01ec74 --- /dev/null +++ b/pract_SI/Pract. 03/Startup_tasks - Solutions/task1_solution2.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int main() +{ + unsigned long long money; //assign money's interval + cin >> money; //enter number of money + + cout << "Initial price: " << money << " = "; //Initial price output + + cout << money / 100 << "*100 + "; //output for 100 + money %= 100; //reduce the 100's + + cout << money / 50 << "*50 + "; //output for 50 + money %= 50; //reduce the 50's + + cout << money / 20 << "*20 + "; //output for 20 + money %= 20; //reduce the 20's + + cout << money / 10 << "*10 + "; //output for 10 + money %= 10; //reduce the 10's + + cout << money / 5 << "*5 + "; //output for 5 + money %= 5; //reduce the 5's + + cout << money / 2 << "*2 + "; //output for 2 + money %= 2; //reduce the 2's + + cout << money / 1 << "*1" << endl; //output for 1 + money %= 1; //reduce the 1's + + cout << "End of program" << endl; //end program + return 0; //end program +} \ No newline at end of file diff --git a/pract_SI/Pract. 03/Startup_tasks - Solutions/task2.cpp b/pract_SI/Pract. 03/Startup_tasks - Solutions/task2.cpp new file mode 100644 index 0000000..ab5ca6f --- /dev/null +++ b/pract_SI/Pract. 03/Startup_tasks - Solutions/task2.cpp @@ -0,0 +1,36 @@ +#include + +using namespace std; + +int main() +{ + unsigned long long velocity; //assign velocity's interval + cin >> velocity; //enter velocity's value + + if (velocity < 10) + cout << "No fine" << endl; + else if (velocity == 10) + cout << "Fine: 20$" << endl; + else if (velocity < 20) + cout << "Fine: 50$" << endl; + else if (velocity < 30) + cout << "Fine: 100$" << endl; + else if (velocity < 40) + cout << "Fine if in Urban area: 400$" << endl //Urban area fine + << "Fine if in Metropolitan area: 300$" << endl; //Metropolitan area fine + else if(velocity <= 50) + cout << "Fine if in Urban area: 600$" << endl //Urban area fine + << "Fine if in Metropolitan area: 400$" << endl;//Metropolitan area fine + else + { + unsigned long long fine = 700 + (((velocity - 50) / 5) * 50); + + + cout << "Fine if in Urban area: " << fine << "$" << endl + << "Additional 3 months driver licence suspension and 12 driver control points." << endl << endl; //Urban area fine + cout << "Fine if in Metropolitan area: " << fine - 100 << "$" << endl;//Metropolitan area fine + } + + cout << endl << "End of program" << endl; //end program + return 0; //end program +} \ No newline at end of file -- cgit v1.3.1-23-gd82d From 76d522c2b556c3d2d3f1c3f199ae611272e49b83 Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Mon, 1 Nov 2021 15:47:22 +0200 Subject: Added Pract. 04 Tasks --- pract_SI/Pract. 04/Task4.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 pract_SI/Pract. 04/Task4.txt (limited to 'pract_SI') diff --git a/pract_SI/Pract. 04/Task4.txt b/pract_SI/Pract. 04/Task4.txt new file mode 100644 index 0000000..cc5f735 --- /dev/null +++ b/pract_SI/Pract. 04/Task4.txt @@ -0,0 +1,32 @@ +#Никола Светославов - task4 + +## Задачи + +1. Да се състави функция sum(const int a, const int b), която приема две числа и връща като резултат сбора им. +2. Да се напише функция isEven(const int num), която връща дали дадено число е четно или не. +3. а)Да се напише функция isPositive(const int num), която връща дали дадено число е положително или не + b)Да се напише функция isNegative(const int num), която връща дали дадено число е отрицателно или не. +4. a)Напишете функция abs(const int num), която връща като резултат абсолютната стойност на числото num. + b)Напишете функция fabs(const double num), която връща като резултат абсолютната стойност на числото num. +5. Напишете функция print(const char S, const int N), която извежда на екрана N-пъти символа S. +6. Напишете функция isCapitalLetter(const char S), която проверява дали даден символ е главна буква. + *Реализирайте функция checkSymbol(const char S), която да проверява дали символът е буква.* +7. a)Напишете функция, която проверява дали дадено число е в интервала [100;10000] + b)Напишете функция, която проверява дали дадено число е в даден интервал. + +8.Напишете функция pow(const int num, const unsigned N), която връща като резултат числото num повдигнато на степен N, където N е строго положително. +9.Напишете функция calculate(const int a, const int b, char action), където action може да бъде [+-*/%]. + Програмата да връща като резултат съответното действие, а ако не се укаже символ да върне сбора на числата +10.Напишете функция, askUser(const int from, const int to), която кара потребителя да въвежда числа докато не въведе число, + което да е в указания интервал, а като резултат връща въпросното число. + +11. Напишете програма, която по въведено число изкарва представянето му в двоична бройна система. + Реализирайте го чрез функция. +12.Да се напише програма, която въвежда стойности на естествените числа a, b, c и d и намира и извежда най-големият общ делител + на числата a и b, след това на c и d и накрая на a, b, c и d. +13.Напишете програма, която получава цяло естествено число в интервала [100;100000]. + Програмата да изведе най - близкото число степен на двойката до това число.(тоест разликата на числата по абсолютна стойност да е минимална). + Входа да се валидира като при грешен ход да се дава възможност за нов опит. + Изкарайте отделните функционалности във функции. + + -- cgit v1.3.1-23-gd82d From 15b1685a4c684b5498473ff1cefa1767bc655d49 Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Tue, 2 Nov 2021 16:23:43 +0200 Subject: Edit&Rename --- pract_SI/Pract. 04/Task4.txt | 32 -------------------------------- pract_SI/Pract. 04/Tasks4.txt | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 pract_SI/Pract. 04/Task4.txt create mode 100644 pract_SI/Pract. 04/Tasks4.txt (limited to 'pract_SI') diff --git a/pract_SI/Pract. 04/Task4.txt b/pract_SI/Pract. 04/Task4.txt deleted file mode 100644 index cc5f735..0000000 --- a/pract_SI/Pract. 04/Task4.txt +++ /dev/null @@ -1,32 +0,0 @@ -#Никола Светославов - task4 - -## Задачи - -1. Да се състави функция sum(const int a, const int b), която приема две числа и връща като резултат сбора им. -2. Да се напише функция isEven(const int num), която връща дали дадено число е четно или не. -3. а)Да се напише функция isPositive(const int num), която връща дали дадено число е положително или не - b)Да се напише функция isNegative(const int num), която връща дали дадено число е отрицателно или не. -4. a)Напишете функция abs(const int num), която връща като резултат абсолютната стойност на числото num. - b)Напишете функция fabs(const double num), която връща като резултат абсолютната стойност на числото num. -5. Напишете функция print(const char S, const int N), която извежда на екрана N-пъти символа S. -6. Напишете функция isCapitalLetter(const char S), която проверява дали даден символ е главна буква. - *Реализирайте функция checkSymbol(const char S), която да проверява дали символът е буква.* -7. a)Напишете функция, която проверява дали дадено число е в интервала [100;10000] - b)Напишете функция, която проверява дали дадено число е в даден интервал. - -8.Напишете функция pow(const int num, const unsigned N), която връща като резултат числото num повдигнато на степен N, където N е строго положително. -9.Напишете функция calculate(const int a, const int b, char action), където action може да бъде [+-*/%]. - Програмата да връща като резултат съответното действие, а ако не се укаже символ да върне сбора на числата -10.Напишете функция, askUser(const int from, const int to), която кара потребителя да въвежда числа докато не въведе число, - което да е в указания интервал, а като резултат връща въпросното число. - -11. Напишете програма, която по въведено число изкарва представянето му в двоична бройна система. - Реализирайте го чрез функция. -12.Да се напише програма, която въвежда стойности на естествените числа a, b, c и d и намира и извежда най-големият общ делител - на числата a и b, след това на c и d и накрая на a, b, c и d. -13.Напишете програма, която получава цяло естествено число в интервала [100;100000]. - Програмата да изведе най - близкото число степен на двойката до това число.(тоест разликата на числата по абсолютна стойност да е минимална). - Входа да се валидира като при грешен ход да се дава възможност за нов опит. - Изкарайте отделните функционалности във функции. - - diff --git a/pract_SI/Pract. 04/Tasks4.txt b/pract_SI/Pract. 04/Tasks4.txt new file mode 100644 index 0000000..cc5f735 --- /dev/null +++ b/pract_SI/Pract. 04/Tasks4.txt @@ -0,0 +1,32 @@ +#Никола Светославов - task4 + +## Задачи + +1. Да се състави функция sum(const int a, const int b), която приема две числа и връща като резултат сбора им. +2. Да се напише функция isEven(const int num), която връща дали дадено число е четно или не. +3. а)Да се напише функция isPositive(const int num), която връща дали дадено число е положително или не + b)Да се напише функция isNegative(const int num), която връща дали дадено число е отрицателно или не. +4. a)Напишете функция abs(const int num), която връща като резултат абсолютната стойност на числото num. + b)Напишете функция fabs(const double num), която връща като резултат абсолютната стойност на числото num. +5. Напишете функция print(const char S, const int N), която извежда на екрана N-пъти символа S. +6. Напишете функция isCapitalLetter(const char S), която проверява дали даден символ е главна буква. + *Реализирайте функция checkSymbol(const char S), която да проверява дали символът е буква.* +7. a)Напишете функция, която проверява дали дадено число е в интервала [100;10000] + b)Напишете функция, която проверява дали дадено число е в даден интервал. + +8.Напишете функция pow(const int num, const unsigned N), която връща като резултат числото num повдигнато на степен N, където N е строго положително. +9.Напишете функция calculate(const int a, const int b, char action), където action може да бъде [+-*/%]. + Програмата да връща като резултат съответното действие, а ако не се укаже символ да върне сбора на числата +10.Напишете функция, askUser(const int from, const int to), която кара потребителя да въвежда числа докато не въведе число, + което да е в указания интервал, а като резултат връща въпросното число. + +11. Напишете програма, която по въведено число изкарва представянето му в двоична бройна система. + Реализирайте го чрез функция. +12.Да се напише програма, която въвежда стойности на естествените числа a, b, c и d и намира и извежда най-големият общ делител + на числата a и b, след това на c и d и накрая на a, b, c и d. +13.Напишете програма, която получава цяло естествено число в интервала [100;100000]. + Програмата да изведе най - близкото число степен на двойката до това число.(тоест разликата на числата по абсолютна стойност да е минимална). + Входа да се валидира като при грешен ход да се дава възможност за нов опит. + Изкарайте отделните функционалности във функции. + + -- cgit v1.3.1-23-gd82d From e55e9fb058a046f6f1e08da521660a8d98b1d5db Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Tue, 2 Nov 2021 16:23:53 +0200 Subject: Added Solutions --- pract_SI/Pract. 04/Solutions/task1.cpp | 34 +++++++++++++++++++++++ pract_SI/Pract. 04/Solutions/task2 - example1.cpp | 23 +++++++++++++++ pract_SI/Pract. 04/Solutions/task2 - example2.cpp | 25 +++++++++++++++++ pract_SI/Pract. 04/Solutions/task3.cpp | 8 ++++++ pract_SI/Pract. 04/Solutions/task4.cpp | 4 +++ pract_SI/Pract. 04/Solutions/task5.cpp | 20 +++++++++++++ pract_SI/Pract. 04/function overload.cpp | 16 +++++++++++ 7 files changed, 130 insertions(+) create mode 100644 pract_SI/Pract. 04/Solutions/task1.cpp create mode 100644 pract_SI/Pract. 04/Solutions/task2 - example1.cpp create mode 100644 pract_SI/Pract. 04/Solutions/task2 - example2.cpp create mode 100644 pract_SI/Pract. 04/Solutions/task3.cpp create mode 100644 pract_SI/Pract. 04/Solutions/task4.cpp create mode 100644 pract_SI/Pract. 04/Solutions/task5.cpp create mode 100644 pract_SI/Pract. 04/function overload.cpp (limited to 'pract_SI') diff --git a/pract_SI/Pract. 04/Solutions/task1.cpp b/pract_SI/Pract. 04/Solutions/task1.cpp new file mode 100644 index 0000000..3e8c1a3 --- /dev/null +++ b/pract_SI/Pract. 04/Solutions/task1.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +int sum(const int a, const int b) +{ + /* + //First way + int sum = a + b; + return sum; + */ + + //Second way + return a + b; +} + +int main() +{ + int num1, num2; + cin >> num1 >> num2; + + //First way + cout << sum(num1, num2) << endl; //return as output on Console + + /* + //Second way + //int sumOfNumbers = sum(num1, num2); //create an int with value num1+num2; + //cout << sumOfNumbers << endl; + */ + + return 0; +} + + diff --git a/pract_SI/Pract. 04/Solutions/task2 - example1.cpp b/pract_SI/Pract. 04/Solutions/task2 - example1.cpp new file mode 100644 index 0000000..309e68d --- /dev/null +++ b/pract_SI/Pract. 04/Solutions/task2 - example1.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +bool isZero(const int number) +{ + return (number == 0); +} + +bool isEven(const int number) +{ + if (isZero(number)) + { + return false; + } + return !(number % 2); +} + +int main() +{ + int n; + cin >> n; + cout << boolalpha << isEven(n) << endl; + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 04/Solutions/task2 - example2.cpp b/pract_SI/Pract. 04/Solutions/task2 - example2.cpp new file mode 100644 index 0000000..0440873 --- /dev/null +++ b/pract_SI/Pract. 04/Solutions/task2 - example2.cpp @@ -0,0 +1,25 @@ +#include + +bool isEven(const int num) { + return !(num % 2); +} + +bool isZero(const int num) { + return num == 0; +} + +int main() { + int num; + std::cin >> num; + if (isZero(num)) { + std::cout << "The number is not ever or odd!"; + } + else { + if (isEven(num)) { + std::cout << "Even"; + return 0; + } + std::cout << "Odd"; + } + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 04/Solutions/task3.cpp b/pract_SI/Pract. 04/Solutions/task3.cpp new file mode 100644 index 0000000..bc85d3a --- /dev/null +++ b/pract_SI/Pract. 04/Solutions/task3.cpp @@ -0,0 +1,8 @@ +bool isPositive(const int num) +{ + if (num <= 0) + { + return false; + } + return true; +} \ No newline at end of file diff --git a/pract_SI/Pract. 04/Solutions/task4.cpp b/pract_SI/Pract. 04/Solutions/task4.cpp new file mode 100644 index 0000000..771550b --- /dev/null +++ b/pract_SI/Pract. 04/Solutions/task4.cpp @@ -0,0 +1,4 @@ +int abs(int num1, int num2) +{ + return ((num1 - num2) >= 0 ? (num1 - num2) : (num2 - num1)); +} \ No newline at end of file diff --git a/pract_SI/Pract. 04/Solutions/task5.cpp b/pract_SI/Pract. 04/Solutions/task5.cpp new file mode 100644 index 0000000..fc5552e --- /dev/null +++ b/pract_SI/Pract. 04/Solutions/task5.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +void print(const int N, const char S = ' ') + { + for (size_t i = 0; i < N; i++) + { + cout << S; + } + } + +int main() +{ + int N; + char S; + cin >> N >> S; + print(N); + cout<< "Error!" << endl; + print(N, S); + return 0; +} \ No newline at end of file diff --git a/pract_SI/Pract. 04/function overload.cpp b/pract_SI/Pract. 04/function overload.cpp new file mode 100644 index 0000000..7e0bdfa --- /dev/null +++ b/pract_SI/Pract. 04/function overload.cpp @@ -0,0 +1,16 @@ +void print() //print - arguments: 0 +{ + cout << "Hello World!\n"; +} + +void print(int number) //print - arguments: 1 + //int +{ + cout << "Hello World N" << number << endl; +} + +void print(double number) //print - arguments: 1 + //double +{ + cout << "Hello World N" << number << endl; +} -- cgit v1.3.1-23-gd82d From ce08cf91ecb8064b61b6851efea044600d8f99c9 Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Wed, 3 Nov 2021 02:05:51 +0200 Subject: Edit Task4 --- pract_SI/Pract. 04/Tasks4.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'pract_SI') diff --git a/pract_SI/Pract. 04/Tasks4.txt b/pract_SI/Pract. 04/Tasks4.txt index cc5f735..4daf06c 100644 --- a/pract_SI/Pract. 04/Tasks4.txt +++ b/pract_SI/Pract. 04/Tasks4.txt @@ -2,25 +2,25 @@ ## Задачи -1. Да се състави функция sum(const int a, const int b), която приема две числа и връща като резултат сбора им. -2. Да се напише функция isEven(const int num), която връща дали дадено число е четно или не. -3. а)Да се напише функция isPositive(const int num), която връща дали дадено число е положително или не - b)Да се напише функция isNegative(const int num), която връща дали дадено число е отрицателно или не. -4. a)Напишете функция abs(const int num), която връща като резултат абсолютната стойност на числото num. - b)Напишете функция fabs(const double num), която връща като резултат абсолютната стойност на числото num. -5. Напишете функция print(const char S, const int N), която извежда на екрана N-пъти символа S. -6. Напишете функция isCapitalLetter(const char S), която проверява дали даден символ е главна буква. - *Реализирайте функция checkSymbol(const char S), която да проверява дали символът е буква.* +1. Да се състави функция sum(int a, int b), която приема две числа и връща като резултат сбора им. +2. Да се напише функция isEven(int num), която връща дали дадено число е четно или не. +3. а)Да се напише функция isPositive(int num), която връща дали дадено число е положително или не + b)Да се напише функция isNegative(int num), която връща дали дадено число е отрицателно или не. +4. a)Напишете функция abs(int num), която връща като резултат абсолютната стойност на числото num. + b)Напишете функция fabs(double num), която връща като резултат абсолютната стойност на числото num. +5. Напишете функция print(char S,int N), която извежда на екрана N-пъти символа S. +6. Напишете функция isCapitalLetter(char S), която проверява дали даден символ е главна буква. + *Реализирайте функция checkSymbol(char S), която да проверява дали символът е буква.* 7. a)Напишете функция, която проверява дали дадено число е в интервала [100;10000] b)Напишете функция, която проверява дали дадено число е в даден интервал. -8.Напишете функция pow(const int num, const unsigned N), която връща като резултат числото num повдигнато на степен N, където N е строго положително. -9.Напишете функция calculate(const int a, const int b, char action), където action може да бъде [+-*/%]. +8.Напишете функция pow(int num,unsigned N), която връща като резултат числото num повдигнато на степен N, където N е строго положително. +9.Напишете функция calculate(nt a,int b, char action), където action може да бъде [+-*/%]. Програмата да връща като резултат съответното действие, а ако не се укаже символ да върне сбора на числата -10.Напишете функция, askUser(const int from, const int to), която кара потребителя да въвежда числа докато не въведе число, +10.Напишете функция, askUser(int from, int to), която кара потребителя да въвежда числа докато не въведе число, което да е в указания интервал, а като резултат връща въпросното число. -11. Напишете програма, която по въведено число изкарва представянето му в двоична бройна система. +11.Напишете програма, която по въведено число изкарва представянето му в двоична бройна система. Реализирайте го чрез функция. 12.Да се напише програма, която въвежда стойности на естествените числа a, b, c и d и намира и извежда най-големият общ делител на числата a и b, след това на c и d и накрая на a, b, c и d. -- cgit v1.3.1-23-gd82d From a43727c44eaeb3164f3ce289a7d08d2974b2a59a Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Wed, 3 Nov 2021 02:10:08 +0200 Subject: Update Pract. Solutions --- pract_SI/Pract. 04/Solutions/task1.cpp | 2 +- pract_SI/Pract. 04/Solutions/task2 - example1.cpp | 10 +--------- pract_SI/Pract. 04/Solutions/task2 - example2.cpp | 24 ++++++++--------------- pract_SI/Pract. 04/Solutions/task3.cpp | 4 +--- pract_SI/Pract. 04/Solutions/task5.cpp | 2 +- 5 files changed, 12 insertions(+), 30 deletions(-) (limited to 'pract_SI') diff --git a/pract_SI/Pract. 04/Solutions/task1.cpp b/pract_SI/Pract. 04/Solutions/task1.cpp index 3e8c1a3..b56d6e1 100644 --- a/pract_SI/Pract. 04/Solutions/task1.cpp +++ b/pract_SI/Pract. 04/Solutions/task1.cpp @@ -2,7 +2,7 @@ using namespace std; -int sum(const int a, const int b) +int sum(int a, int b) { /* //First way diff --git a/pract_SI/Pract. 04/Solutions/task2 - example1.cpp b/pract_SI/Pract. 04/Solutions/task2 - example1.cpp index 309e68d..25b4030 100644 --- a/pract_SI/Pract. 04/Solutions/task2 - example1.cpp +++ b/pract_SI/Pract. 04/Solutions/task2 - example1.cpp @@ -1,16 +1,8 @@ #include using namespace std; -bool isZero(const int number) -{ - return (number == 0); -} -bool isEven(const int number) +bool isEven(int number) { - if (isZero(number)) - { - return false; - } return !(number % 2); } diff --git a/pract_SI/Pract. 04/Solutions/task2 - example2.cpp b/pract_SI/Pract. 04/Solutions/task2 - example2.cpp index 0440873..2d365ba 100644 --- a/pract_SI/Pract. 04/Solutions/task2 - example2.cpp +++ b/pract_SI/Pract. 04/Solutions/task2 - example2.cpp @@ -1,25 +1,17 @@ #include -bool isEven(const int num) { +bool isEven(int num) { return !(num % 2); } -bool isZero(const int num) { - return num == 0; -} - -int main() { +int main() +{ int num; std::cin >> num; - if (isZero(num)) { - std::cout << "The number is not ever or odd!"; - } - else { - if (isEven(num)) { - std::cout << "Even"; - return 0; - } - std::cout << "Odd"; - } + + if (isEven(num)) + std::cout << "Even"; + else + std::cout << "Odd"; return 0; } \ No newline at end of file diff --git a/pract_SI/Pract. 04/Solutions/task3.cpp b/pract_SI/Pract. 04/Solutions/task3.cpp index bc85d3a..60622e2 100644 --- a/pract_SI/Pract. 04/Solutions/task3.cpp +++ b/pract_SI/Pract. 04/Solutions/task3.cpp @@ -1,8 +1,6 @@ -bool isPositive(const int num) +bool isPositive(int num) { if (num <= 0) - { return false; - } return true; } \ No newline at end of file diff --git a/pract_SI/Pract. 04/Solutions/task5.cpp b/pract_SI/Pract. 04/Solutions/task5.cpp index fc5552e..42b5fc6 100644 --- a/pract_SI/Pract. 04/Solutions/task5.cpp +++ b/pract_SI/Pract. 04/Solutions/task5.cpp @@ -1,6 +1,6 @@ #include using namespace std; -void print(const int N, const char S = ' ') +void print(int N, char S = ' ') { for (size_t i = 0; i < N; i++) { -- cgit v1.3.1-23-gd82d From 99905d88c0e6c4c35472a9058e256883d19f4afd Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Wed, 3 Nov 2021 02:18:52 +0200 Subject: Update/Refactor --- pract_SI/Pract. 04/Solutions/task3.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'pract_SI') diff --git a/pract_SI/Pract. 04/Solutions/task3.cpp b/pract_SI/Pract. 04/Solutions/task3.cpp index 60622e2..937b833 100644 --- a/pract_SI/Pract. 04/Solutions/task3.cpp +++ b/pract_SI/Pract. 04/Solutions/task3.cpp @@ -1,6 +1,4 @@ bool isPositive(int num) { - if (num <= 0) - return false; - return true; + return (num > 0); } \ No newline at end of file -- cgit v1.3.1-23-gd82d