From 7881119e0914b9207568918fcf868eea84ef3d78 Mon Sep 17 00:00:00 2001 From: Angeld55 Date: Sat, 28 Nov 2020 01:45:44 +0200 Subject: sem 8 --- .../Tasks and Solutions/01. Between100and200.cpp | 15 ++++ Sem. 03/Tasks and Solutions/02. Speed check.cpp | 19 +++++ Sem. 03/Tasks and Solutions/03. Figures.cpp | 28 +++++++ Sem. 03/Tasks and Solutions/04. Time + 15.cpp | 21 +++++ Sem. 03/Tasks and Solutions/05. Chainsaw.cpp | 16 ++++ Sem. 03/Tasks and Solutions/06. DivBy3.cpp | 11 +++ Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp | 20 +++++ .../Tasks and Solutions/08. DuplicateDigits.cpp | 93 +++++++++++++++++++++ Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp | 18 ++++ Sem. 03/Tasks and Solutions/10. Pyramid.cpp | 14 ++++ Sem. 03/Tasks and Solutions/11. Clock.cpp | 18 ++++ Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp | 31 +++++++ .../13. ClockWithStartAndEnd.cpp | 41 +++++++++ Sem. 03/Tasks and Solutions/14. Frame.cpp | 30 +++++++ Sem. 03/Tasks and Solutions/tasks.pdf | Bin 0 -> 449792 bytes 15 files changed, 375 insertions(+) create mode 100644 Sem. 03/Tasks and Solutions/01. Between100and200.cpp create mode 100644 Sem. 03/Tasks and Solutions/02. Speed check.cpp create mode 100644 Sem. 03/Tasks and Solutions/03. Figures.cpp create mode 100644 Sem. 03/Tasks and Solutions/04. Time + 15.cpp create mode 100644 Sem. 03/Tasks and Solutions/05. Chainsaw.cpp create mode 100644 Sem. 03/Tasks and Solutions/06. DivBy3.cpp create mode 100644 Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp create mode 100644 Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp create mode 100644 Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp create mode 100644 Sem. 03/Tasks and Solutions/10. Pyramid.cpp create mode 100644 Sem. 03/Tasks and Solutions/11. Clock.cpp create mode 100644 Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp create mode 100644 Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp create mode 100644 Sem. 03/Tasks and Solutions/14. Frame.cpp create mode 100644 Sem. 03/Tasks and Solutions/tasks.pdf (limited to 'Sem. 03/Tasks and Solutions') diff --git a/Sem. 03/Tasks and Solutions/01. Between100and200.cpp b/Sem. 03/Tasks and Solutions/01. Between100and200.cpp new file mode 100644 index 0000000..0817bcc --- /dev/null +++ b/Sem. 03/Tasks and Solutions/01. Between100and200.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; + +int main() +{ + unsigned int n; + cin >> n; + + if (n < 100) + cout << "Less than 100" << endl; + else if (n <= 200) + cout << "Between 100 and 200" << endl; + else + cout << "More than 200" << endl; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/02. Speed check.cpp b/Sem. 03/Tasks and Solutions/02. Speed check.cpp new file mode 100644 index 0000000..4660382 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/02. Speed check.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; + +int main() +{ + double speed; + cin >> speed; + + if (speed <= 10) + cout << "Slow" << endl; + else if (speed < 50) + cout << "Average" << endl; + else if (speed < 150) + cout << "Fast" << endl; + else if (speed < 1000) + cout << "Ultra fast" << endl; + else + cout << "Extremely fast" << endl; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/03. Figures.cpp b/Sem. 03/Tasks and Solutions/03. Figures.cpp new file mode 100644 index 0000000..170c403 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/03. Figures.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; + +const double PI = 3.14; +int main() +{ + char figure; + cin >> figure; + + if (figure == 's') + { + double side; + cin >> side; + cout << side * side << endl; + } + else if (figure == 'r') + { + double sideA, sideB; + cin >> sideA >> sideB; + cout << sideA * sideB << endl; + } + else if (figure == 'c') + { + double R; + cin >> R; + cout << PI * R * R << endl; + } +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/04. Time + 15.cpp b/Sem. 03/Tasks and Solutions/04. Time + 15.cpp new file mode 100644 index 0000000..aee3118 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/04. Time + 15.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +const double PI = 3.14; +int main() +{ + int hours, mins; + cin >> hours >> mins; + + (mins += 15) %= 60; + + if (mins < 15) + (hours+=1)%=24; + + if (hours <= 9) + cout << 0; + cout << hours << ":"; + if (mins <= 9) + cout << 0; + cout << mins << endl; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp b/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp new file mode 100644 index 0000000..68940e0 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/05. Chainsaw.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main() +{ + int a, b, c, d, e; + cin >> a >> b >> c >> d >> e; + + if ((a <= b && b >= c && c <= d && d >= e) + || (a >= b && b <= c && c >= d && d <= e)) + { + cout << "Yes"; + } + else + cout << "No"; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/06. DivBy3.cpp b/Sem. 03/Tasks and Solutions/06. DivBy3.cpp new file mode 100644 index 0000000..044aee9 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/06. DivBy3.cpp @@ -0,0 +1,11 @@ +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + + for (int i = 3; i <= n; i+=3) + cout << i << endl; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp new file mode 100644 index 0000000..4ae1131 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ + int n, searchedDigit; + cin >> n >> searchedDigit; + + bool found = false; + while (n != 0) + { + int lastDigit = n % 10; + if (searchedDigit == lastDigit) + { + found = true; + break; + } + n /= 10; + } +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp b/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp new file mode 100644 index 0000000..0fa5946 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/08. DuplicateDigits.cpp @@ -0,0 +1,93 @@ +#include +using namespace std; + +int main() +{ + bool found0, found1, found2, found3, found4, found5, found6, found7, found8, found9; + found0 = found1 = found2 = found3 = found4 = found5 = found6 = found7 = found8 = found9 = false; + + int n; + cin >> n; + + bool foundDuplicate = false; + while (!foundDuplicate && n != 0) + { + int lastDigit = n % 10; + switch (lastDigit) + { + case 0: + if (found0) + { + foundDuplicate = true; + + } + found0 = true; + break; + case 1: + if (found1) + { + foundDuplicate = true; + } + found1 = true; + break; + case 2: + if (found2) + { + foundDuplicate = true; + } + found2 = true; + break; + case 3: + if (found3) + { + foundDuplicate = true; + } + found3 = true; + break; + case 4: + if (found4) + { + foundDuplicate = true; + } + found4 = true; + break; + case 5: + if (found5) + { + foundDuplicate = true; + } + found5 = true; + break; + case 6: + if (found6) + { + foundDuplicate = true; + } + found6 = true; + break; + case 7: + if (found7) + { + foundDuplicate = true; + } + found7 = true; + break; + case 8: + if (found8) + { + foundDuplicate = true; + } + found8 = true; + case 9: + if (found9) + { + foundDuplicate = true; + } + found9 = true; + break; + } + n /= 10; + } + + cout << foundDuplicate; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp b/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp new file mode 100644 index 0000000..aea318a --- /dev/null +++ b/Sem. 03/Tasks and Solutions/09. SumFromKtoN.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; + +int main() +{ + int n, k; + cin >> k >> n; + + int sum = 0; + for (int i = k; i <= n; i++) + sum += i; + + cout << sum << endl; + + //or use the formula + + cout << (n*(n + 1)) / 2 - ((k - 1)*k) / 2 << endl; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/10. Pyramid.cpp b/Sem. 03/Tasks and Solutions/10. Pyramid.cpp new file mode 100644 index 0000000..5d9e2a9 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/10. Pyramid.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= i; j++) + cout << "$"; + cout << endl; + } +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/11. Clock.cpp b/Sem. 03/Tasks and Solutions/11. Clock.cpp new file mode 100644 index 0000000..6386ca0 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/11. Clock.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; + +int main() +{ + for (int hour = 0; hour <= 23; hour++) + { + for (int min = 0; min <= 59; min++) + { + if (hour < 10) + cout << 0; + cout << hour << ":"; + if (min < 10) + cout << 0; + cout << min << endl; + } + } +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp b/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp new file mode 100644 index 0000000..1b996e1 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/12. ClockWithStart.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; + +int main() +{ + int h, m; + cin >> h >> m; + + for (int min = m + 1; min <= 59; min++) + { + if (h < 10) + cout << 0; + cout << h << ":"; + if (min < 10) + cout << 0; + cout << min << endl; + } + + for (int hour = h+1; hour <= 23; hour++) + { + for (int min = 0; min <= 59; min++) + { + if (hour < 10) + cout << 0; + cout << hour << ":"; + if (min < 10) + cout << 0; + cout << min << endl; + } + } +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp b/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp new file mode 100644 index 0000000..af39745 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/13. ClockWithStartAndEnd.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; + +int main() +{ + int hStart, mStart, hEnd, mEnd; + cin >> hStart >> mStart >> hEnd >> mEnd; + + for (int min = mStart + 1; min <= 59; min++) + { + if (hStart < 10) + cout << 0; + cout << hStart << ":"; + if (min < 10) + cout << 0; + cout << min << endl; + } + + for (int hour = hStart+1; hour <= hEnd-1; hour++) + { + for (int min = 0; min <= 59; min++) + { + if (hour < 10) + cout << 0; + cout << hour << ":"; + if (min < 10) + cout << 0; + cout << min << endl; + } + } + + for (int min = 0; min < mEnd; min++) + { + if (hEnd < 10) + cout << 0; + cout << hEnd << ":"; + if (min < 10) + cout << 0; + cout << min << endl; + } +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/14. Frame.cpp b/Sem. 03/Tasks and Solutions/14. Frame.cpp new file mode 100644 index 0000000..92de3ca --- /dev/null +++ b/Sem. 03/Tasks and Solutions/14. Frame.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + + //Горна рамка + cout << '+'; + for (int i = 0; i < n - 2; i++) + cout << '-'; + cout << '+' << endl; + + + //Среда + for (int j = 0; j < n - 2; j++) + { + cout << '|'; + for (int i = 0; i < n - 2; i++) + cout << '-'; + cout << '|' << endl; + } + + //Долна рамка + cout << '+'; + for (int i = 0; i < n - 2; i++) + cout << '-'; + cout << '+' << endl; +} \ No newline at end of file diff --git a/Sem. 03/Tasks and Solutions/tasks.pdf b/Sem. 03/Tasks and Solutions/tasks.pdf new file mode 100644 index 0000000..6c2ad50 Binary files /dev/null and b/Sem. 03/Tasks and Solutions/tasks.pdf differ -- cgit v1.3.1-26-gb76a