diff options
Update Pract. Solutions
5 files changed, 12 insertions, 30 deletions
| -rw-r--r-- | pract_SI/Pract. 04/Solutions/task1.cpp | 2 | ||||
| -rw-r--r-- | pract_SI/Pract. 04/Solutions/task2 - example1.cpp | 10 | ||||
| -rw-r--r-- | pract_SI/Pract. 04/Solutions/task2 - example2.cpp | 24 | ||||
| -rw-r--r-- | pract_SI/Pract. 04/Solutions/task3.cpp | 4 | ||||
| -rw-r--r-- | pract_SI/Pract. 04/Solutions/task5.cpp | 2 |
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 <iostream> 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 <iostream> -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 <iostream> 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++) { |
