From fe1cc4cbaed4fd59ef869964e133fa031e08e5cc Mon Sep 17 00:00:00 2001 From: Martin Kirchev Date: Fri, 18 Oct 2024 15:21:10 +0300 Subject: [PATCH 1/7] Test push --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e915029 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs From 4d6a8a91ca34f43d8a658942146416be7ce9e484 Mon Sep 17 00:00:00 2001 From: "Martin K." Date: Wed, 30 Oct 2024 21:38:18 +0200 Subject: [PATCH 2/7] Seminar01 --- .gitignore | 3 + CppProperties.json | 21 +++++ MySolutions/Seminar01.cpp | 180 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 CppProperties.json create mode 100644 MySolutions/Seminar01.cpp diff --git a/.gitignore b/.gitignore index e915029..87529a5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ ################################################################################ /.vs +/.gitignore +/.gitignore +/.gitignore diff --git a/CppProperties.json b/CppProperties.json new file mode 100644 index 0000000..6017def --- /dev/null +++ b/CppProperties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "inheritEnvironments": [ + "msvc_x64" + ], + "name": "x64-Release", + "includePath": [ + "${env.INCLUDE}", + "${workspaceRoot}\\**" + ], + "defines": [ + "WIN32", + "NDEBUG", + "UNICODE", + "_UNICODE" + ], + "intelliSenseMode": "windows-msvc-x64" + } + ] +} \ No newline at end of file diff --git a/MySolutions/Seminar01.cpp b/MySolutions/Seminar01.cpp new file mode 100644 index 0000000..1c65321 --- /dev/null +++ b/MySolutions/Seminar01.cpp @@ -0,0 +1,180 @@ +// MK_Project.cpp : This file contains the 'main' function. Program execution begins and ends there. + +#include +using namespace std; + +int main() +{ + // Zad_1 + //cout << "Oh what \na happy day! \nOh yes, \nwhat a happy day!\n"; + + // Zad_2 + //double a = 5.4; + //double b = 7.9; + + //double P = 2 * a + 2 * b; + //double S = a * b; + + //cout << "P: " << P + // << "\nS: " << S << "\n"; + + // Zad_3 + //double BGN; + //cin >> BGN; + + //double USD = BGN * 0.51; + //double EUR = BGN * 0.56; + + //cout << "USD: " << USD + // << "\nEUR:" << EUR << "\n"; + + // Zad_4 + //cout << "Please enter the length of the first side: "; + + //double a; + //cin >> a; + + //cout << "\nPlease enter the length of the second side: "; + + //double b; + //cin >> b; + + //double P = 2 * a + 2 * b; + //double S = a * b; + + //cout << "\nP: " << P + // << "\nS: " << S << "\n"; + + // Zad_5 + //int num1, num2; + //cin >> num1 >> num2; + + //bool biggerThanFirst = (num1 > num2); + + //cout << biggerThanFirst; + + // Zad_6 + //int num1, num2; + + //cout << "Dividend: "; + //cin >> num1; + + //cout << "Divisor: "; + //cin >> num2; + + //cout << "The quotient of the division is : " << num1 / num2 << "\n"; + //cout << "The remainder of the division is : " << num1 % num2 << "\n"; + + // Zad_7 + //int apples, pears, bananas; + + //cout << "Apples: "; + //cin >> apples; + + //cout << "Pears: "; + //cin >> pears; + + //cout << "Bananas: "; + //cin >> bananas; + + //cout << "Pesho, don’t forget to buy " << apples << " apples, " << pears << " pears and " << bananas << " bananas!\n"; + + // Zad_8 + //double r; + //double d = r * 2; + //double PI = 3.14159265; + + //cout << "r = "; + //cin >> r; + + //double C = 2 * PI * d; + //cout << "C = " << C << "\n"; + + //double S = PI * r * r; + //cout << "S = " << S << "\n"; + + // Zad_9 + //int a, b, c; + //cin >> a >> b >> c; + + //int D = b * b - 4 * a * c; + //int x1 = (- b - sqrt(D)) / (2 * a); + //int x2 = (- b + sqrt(D)) / (2 * a); + + //cout << "x1 = " << x1 << ", x2 = " << x2; + + // Zad_10 + //int num1, num2; + //cin >> num1 >> num2; + + //cout << num1 << " " << num2 << "\n"; + + //int variable = num1; + //num1 = num2; + //num2 = variable; + + //cout << num1 << " " << num2 << "\n"; + + //Yslovie 2 + + //int num1, num2; + //cin >> num1 >> num2; + + //cout << num1 << " " << num2 << "\n"; + + //num1 = num1 + num2; + //num2 = num1 - num2; + //num1 = num1 - num2; + + //cout << num1 << " " << num2 << "\n"; + + //Zad_11 + //int num1, num2; + //cin >> num1 >> num2; + + //bool is_a_bigger = num1 > num2; + //bool is_b_bigger = num1 < num2; + + //cout << "Max: " << ((is_a_bigger * num1) + (is_b_bigger * num2)) << endl << "Min: " << ((is_b_bigger * num1) + (is_a_bigger * num2)); + + //Zad_12 + //int secondsInput; + //cout << "Seconds: "; + //cin >> secondsInput; + + // 60 sec -> 1 min + // 60 min - 1 hour + // 24 hours - 1 day + // 60 * 60 * 24 = 86400 + + //int days = secondsInput / 86400; + //secondsInput %= 86400; + + //int hours = secondsInput / 3600; + //secondsInput %= 3600; + + //int minutes = secondsInput / 60; + //secondsInput %= 60; + + //int seconds = secondsInput; + + //cout << days << " days, " << hours << " hours, " << minutes << " minutes and " << seconds << " seconds\n"; + + //Zad_13 + //double x1, y1; + //double x2, y2; + + //cin >> x1 >> y1; + //cin >> x2 >> y2; + + //double distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); + //cout << distance; + + //Zad_14 + //int n; + //cout << "n: "; + //cin >> n; + + //cout << (n * (n + 1)) / 2; + +} \ No newline at end of file From 24e97c3d88497b41cc1b3b55381e9fc046c89644 Mon Sep 17 00:00:00 2001 From: "Martin K." Date: Fri, 1 Nov 2024 14:56:47 +0200 Subject: [PATCH 3/7] Seminar02 --- MySolutions/Seminar01.cpp | 2 +- MySolutions/Seminar02.cpp | 310 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 MySolutions/Seminar02.cpp diff --git a/MySolutions/Seminar01.cpp b/MySolutions/Seminar01.cpp index 1c65321..ad17c69 100644 --- a/MySolutions/Seminar01.cpp +++ b/MySolutions/Seminar01.cpp @@ -168,7 +168,7 @@ int main() //cin >> x2 >> y2; //double distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); - //cout << distance; + //cout << (ceil(distance * 100.0) / 100.0); //Zad_14 //int n; diff --git a/MySolutions/Seminar02.cpp b/MySolutions/Seminar02.cpp new file mode 100644 index 0000000..e0b6441 --- /dev/null +++ b/MySolutions/Seminar02.cpp @@ -0,0 +1,310 @@ +// MK_Project.cpp : This file contains the 'main' function. Program execution begins and ends there. + +#include +using namespace std; + +int main() +{ + + // Zad_1 + //int year; + //cin >> year; + + //if (year % 400 == 0) { + + // cout << year << " is Leap year. \n"; + + //} + //else if (year % 100 == 0) { + + // cout << year << " isn't Leap year. \n"; + + //}else if (year % 4 == 0) { + + // cout << year << " is Leap year. \n"; + + //} + //else { + + // cout << year << " isn't Leap year. \n"; + + //} + + // Zad_2 + //char symbol; + //cin >> symbol; + + //if ((symbol >= 65 && symbol <= 90) || (symbol >= 97 && symbol <= 122)) { + + // if ((symbol == 'a') || (symbol == 'e') || (symbol == 'i') || + // (symbol == 'o') || (symbol == 'u')) { + + // cout << symbol << " is Vowel letter. \n"; + + // } + // else + // { + + // cout << symbol << " is Consonant letter. \n"; + + // } + //} + //else + //{ + + // cout << symbol << " isn't a letter. \n"; + + //} + + // Zad_3 + //int num1, num2; + //cin >> num1 >> num2; + + //cout << ((num1 > num2) ? num1 : num2); + + // Zad_4 + //int percentage; + //cout << "Result: "; + //cin >> percentage; + + //cout << "Grade: "; + + //if (percentage >= 90) { + + // cout << "6+"; + + //} else if (percentage >= 80) { + + // cout << "6"; + + //}else if (percentage >= 70) { + + // cout << "5"; + + //}else if (percentage >= 60) { + + // cout << "4"; + + //}else if (percentage >= 40) { + + // cout << "3"; + + //}else { + + // cout << "2"; + + //} + + // Zad_5 + //int a, b, c; + //cin >> a >> b >> c; + + //if ((a + b > c) && (b + c > a) && (a + c > b)) { + + // cout << "VALID"; + //} + //else + //{ + // cout << "NOT VALID"; + //} + + // Zad_6 + //int trafficLightState; + //cout << "Enter traffic light state: \n"; + + //cin >> trafficLightState; + // + //switch (trafficLightState) { + // + //case 1: cout << "Green. You can pass! "; break; + // + //case 0: cout << "Yellow. Warning!"; + // + //case -1: cout << "Red. You cannot pass!"; break; + //} + + // Zad_7 + //char symbol; + //cin >> symbol; + + //if ((symbol >= 65 && symbol <= 90) || (symbol >= 97 && symbol <= 122)) { + + // if (islower(symbol)) { + + // cout << ((char) toupper(symbol)); + + // } + // else + // { + + // cout << ((char) tolower(symbol)); + // } + //} + //else + //{ + // + // cout << "Invalid character"; + //} + + // Zad_8 + //int number; + + //cout << "Arabic numeral: "; + //cin >> number; + + //cout << "Roman numerals: "; + + //if (number == 1) { + + // cout << "I"; + + //}else if (number == 2) { + + // cout << "II"; + + //}else if (number == 3) { + + // cout << "III"; + + //}else if (number == 4) { + + // cout << "IV"; + + //}else if (number == 5) { + + // cout << "V"; + + //}else if (number == 6) { + + // cout << "VI"; + + //}else if (number == 7) { + + // cout << "VII"; + + //}else if (number == 8) { + + // cout << "VIII"; + + //}else if (number == 9) { + + // cout << "IX"; + + //} + + // Zad_9 + //int num1, num2, num3; + //cin >> num1 >> num2 >> num3; + + //int sum = num1 + num2 + num3; + //int maxNum = max(max(num1, num2), num3); + //int minNum = min(min(num1, num2), num3); + //int middle = sum - maxNum - minNum; + + //cout << minNum << " " << middle << " " << maxNum; + + // Zad_10 + //double num1, num2; + //cin >> num1 >> num2; + + //char action; + + //cout << "Action: "; + //cin >> action; + + //if (action == '+') { + + // cout << num1 + num2; + + //}else if (action == '-') { + + // cout << num1 - num2; + + //}else if (action == '*') { + + // cout << num1 * num2; + + //}else if (action == '/') { + + // if (num2 == 0) { + + // cout << "undefined"; + + // } + // else + // { + + // cout << num1 / num2; + // } + //} + + // Zad_11 + //int num1, num2, num3; + //cin >> num1 >> num2 >> num3; + // + //int sum = num1 + num2 + num3; + //int maxNum = max(max(num1, num2), num3); + //int minNum = min(min(num1, num2), num3); + //int middle = sum - maxNum - minNum; + // + //cout << maxNum << middle << minNum; + + // Zad_12 + //int day, month; + + //cout << "Date: "; + //cin >> day >> month; + + //day++; + + //if (month % 2 == 0) { + + // if (month == 2) { + + // if (day > 28) { + + // day = 1; + // month++; + // } + + // } + // else + // { + // if (month == 12) { + + // if (day > 31) { + + // day = 1; + // month = 1; + // } + + + // }else if (day > 31) { + + // day = 1; + // month++; + // } + + // } + + //} + //else { + + // if (day > 30) { + + // day = 1; + // month = 1; + // } + + //} + + //cout << "Next date: " << day << " " << month; + + // Zad_13 + //int num1, num2, num3; + //cin >> num1 >> num2 >> num3; + + //int maxNum = ( (num1 > num2) ? ( (num1 > num3) ? num1 : num3 ) : ( (num2 > num3) ? num2 : num3) ); + //cout << "Max: " << maxNum; + +} \ No newline at end of file From b3ff54e3943ef6d838dd9c84de0ea4c7072c8522 Mon Sep 17 00:00:00 2001 From: "Martin K." Date: Fri, 1 Nov 2024 23:08:33 +0200 Subject: [PATCH 4/7] Seminar03 --- MySolutions/Seminar03.cpp | 584 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 584 insertions(+) create mode 100644 MySolutions/Seminar03.cpp diff --git a/MySolutions/Seminar03.cpp b/MySolutions/Seminar03.cpp new file mode 100644 index 0000000..a7306fa --- /dev/null +++ b/MySolutions/Seminar03.cpp @@ -0,0 +1,584 @@ +// MK_Project.cpp : This file contains the 'main' function. Program execution begins and ends there. + +#include +using namespace std; + +bool isPrime(int num) { + + for (int i = 2; i < num / 2; i++) + { + + if (num % i == 0) { + + return false; + } + } + + return true; +} + +bool isRightTriangle(int a, int b, int c) { + + if ((a + b > c) && (b + c > a) && (a + c > b)) { + + if (pow(a, 2) + pow(b, 2) == pow(c, 2)) { + + return true; + } + } + + return false; +} + +int main() +{ + + // Zad_1 + // + //int n; + //cin >> n; + + //int counter = 1; + //int factorial = 1; + + //while (counter != n + 1) { + + // factorial *= counter; + + // counter++; + //} + + //cout << "Factorial: " << factorial; + + + // Zad_2 + // + //int n, m; + + //cout << "Start: "; + //cin >> n; + // + //cout << "End: "; + //cin >> m; + + //if ( (n < 0) || (m > 255) ) { + + // cout << "Invalid codes!"; + // return 0; + //} + + + //for (int counter = n; counter <= m; counter++) + //{ + + // cout << counter << " --> " << (char) counter << "\n"; + //} + + + // Zad_3 + // + //int n; + //cin >> n; + + //for (int x = 1; x < n; x++) + //{ + // for (int y = 1; y < n; y++) + // { + + // if (x + y == n) { + + // cout << "x = " << x << ", y = " << y << "\n"; + // } + // } + //} + + + // Zad_4 + // + //int n; + //cin >> n; + + //int sum = 0; + + //while (n != 0) { + + // sum += n % 10; + // n /= 10; + + //} + + //cout << sum; + + //Bonus + //int n; + //cin >> n; + + //int sum = 0; + + //while (n != 0) { + + // sum += n % 10; + // n /= 10; + + // if ((n == 0) && (sum > 9)) { + + // n = sum; + // sum = 0; + // } + //} + + //cout << sum; + + + // Zad_5 + // + //int num; + //cin >> num; + + //int secondNum = num * num; + // + //while (secondNum != 0) { + + // if (secondNum % 10 != 0) { + + // cout << secondNum % 10; + // } + + // secondNum /= 10; + //} + + + // Zad_6 + // + //int m, n; + //cin >> m >> n; + + //int counter = 1; + + //for (int row = 1; row <= m; row++) + //{ + // for (int column = 1; column <= n; column++) + // { + + // cout << counter++ << " "; + // } + + // cout << "\n"; + //} + + + // Zad_7 + // + //int sum = 0; + // + //for (int n = 101; n <+ 999; n += 2) + //{ + // if (isPrime(n)) { + + // sum += n; + // } + //} + + //cout << sum; + + + // Zad_8 + // + //int n; + //cin >> n; + + //int previousNum = 0; + //int currentNum = 1; + + //if (n == 1) { + + // cout << previousNum; + // return 0; + + //} + //else if (n == 0) { + + // return 0; + //} + + //cout << previousNum << " " << currentNum << " "; + + //for (int i = 2; i < n; i++) + //{ + + // int sum = previousNum + currentNum; + // cout << sum << " "; + + // previousNum = currentNum; + // currentNum = sum; + //} + + + // Zad_9 + // + //int n, m; + //cin >> n >> m; + + //int sum = 0; + + //for (int num = n; num <= m; num++) + //{ + + // if (isPrime(num)) { + + // sum += num; + // } + //} + + //cout << "Sum of primes: " << sum; + + + // Zad_10 + // + //int n; + //cin >> n; + + //int sum = (n * (n + 1)) / 2; + + //for (int num = 1; num < n; num++) + //{ + + // int tempNumber; + // cin >> tempNumber; + + // sum -= tempNumber; + //} + + //cout << sum; + + + // Zad_11 + // + //int num; + //bool isBadNum = true; + + //while (isBadNum) { + + // cin >> num; + + // int copyNum = num; + // int sum = 0; + + // while (copyNum != 0) { + + // sum += copyNum % 10; + // copyNum /= 10; + // } + + // if ((num + sum) % 10 == 0) { + + // isBadNum = false; + // continue; + // } + + // cout << "Bad number. \n"; + // } + + + // Zad_12 + // + //int n; + + //cout << "n = "; + //cin >> n; + + //int sum = 0; + + //for (int i = 1; i <= n; i++) + //{ + // for (int j = 1; j <= i; j++) + // { + + //cout << sum; + + + // Zad_13 + + //int hour1, minute1; + //cin >> hour1 >> minute1; + + //int hour2, minute2; + //cin >> hour2 >> minute2; + + //int time1 = hour1 * 60 + minute1; + //int time2 = hour2 * 60 + minute2; + + //int biggerTime = (time1 > time2) ? time1 : time2; + //int smallerTime = (time1 < time2) ? time1 : time2; + + //for (int t = smallerTime; t <= biggerTime; t++) + //{ + + // string printStr1 = ""; + // string printStr2 = ":"; + // int hr = t / 60; + // int min = t % 60; + + // if (hr < 10) { + + // printStr1 = "0"; + + // } + + // if (min < 10) { + + // printStr2 = ":0"; + + // } + // + + // cout << printStr1 << hr << printStr2 << min << "\n"; + //} + + + // Zad_14 + + /*int n; + cin >> n; + + int sum = 0; + + while (true) { + + int num; + cin >> num; + + if (num == -1) { + + break; + } + + if (isPrime(num) && (n % num != 0)) { + + sum += num; + } + } + + cout << sum;*/ + + // Zad_15 + + //int n; + //cin >> n; + + //for (int a = 1; a <= n; a++) + //{ + // for (int b = 1; b <= n; b++) + // { + // for (int c = 1; c <= n; c++) + // { + + // if (isRightTriangle(a, b, c)) { + + // cout << a << " " << b << " " << c << "\n"; + // } + // } + // } + //} + + + // Zad_16 + + //int m, n; + //cin >> m >> n; + + //for (int count = m; count <= n; count++) + //{ + + // int sum = 0; + + // for (int i = 1; i < count; i++) + // { + + // if (count % i == 0) { + + // sum += i; + // } + // } + + // if (count == sum) { + + // cout << count << "\n"; + // } + //} + + + // Zad_17 + + /*int n; + cin >> n; + + int previousSum = 0; + int maxDiff = 0; + + for (int i = 1; i <= n; i++) + { + + int num1, num2; + cin >> num1 >> num2; + + if (i == 1) { + + previousSum = num1 + num2; + continue; + } + + int currentSum = num1 + num2; + int difference = abs(previousSum - currentSum); + + if (currentSum != previousSum) { + + if (maxDiff < difference) { + + maxDiff = difference; + } + } + + previousSum = num1 + num2; + } + + if (maxDiff != 0) { + + cout << "Different sums. Max Difference: " << maxDiff; + + } + else { + + cout << "Equal sums: " << previousSum; + }*/ + + + // Zad_18 + + //int k; + //cin >> k; + + //int n, m; + //cin >> n >> m; + + //for (int num = n; num <= m; num++) + //{ + + // int copyNum = num; + // bool isSpetial = true; + + // while (copyNum != 0) { + + // int copyNumNumber = copyNum % 10; + + // if (copyNumNumber == 0 || k % copyNumNumber != 0) { + + // isSpetial = false; + // break; + // } + + // copyNum /= 10; + // } + + // if (isSpetial) { + + // cout << num << " "; + // } + //} + + + // Zad_19 + + //int n; + //cin >> n; + + //for (int i = 1; i <= n; i++) + //{ + // for (int j = 1; j <= i; j++) + // { + // cout << "$ "; + // } + + // cout << "\n"; + //} + + + // Zad_20 (???? ? ????? ???? ?? ??????????? ?????) + + /*int n; + cin >> n; + + for (int row = 1; row <= n; row++) + { + for (int num1 = 1; num1 <= row; num1++) + { + cout << num1 << " "; + } + + for (int symbol = n; symbol > row; symbol--) + { + cout << " "; + } + + for (int symbol = 1; symbol <= n; symbol++) + { + if (row != n) { + + cout << " "; + + } + else { + + cout << "-"; + + } + + } + + for (int symbol = n; symbol > row; symbol--) + { + cout << " "; + } + + for (int num2 = 1; num2 <= row; num2++) + { + cout << " " << row - (num2 - 1); + } + + cout << "\n"; + } + + int counter = 1; + + for (int row = 1; row < n; row++) + { + + for (int num1 = 1; num1 <= n - row; num1++) + { + cout << num1 << " "; + } + + for (int symbol = 1; symbol <= row; symbol++) + { + cout << " "; + } + + for (int symbol = 1; symbol <= n; symbol++) + { + cout << " "; + } + + for (int symbol = 1; symbol <= row; symbol++) + { + cout << " "; + } + + for (int num2 = n - row; num2 >= 1; num2--) + { + cout << " " << num2; + } + + cout << "\n"; + }*/ + +} \ No newline at end of file From 543e1223b2d291b73929876bc58bc3cf1777e5ad Mon Sep 17 00:00:00 2001 From: "Martin K." <95297189+Martin-Kirchev@users.noreply.github.com> Date: Fri, 1 Nov 2024 23:11:07 +0200 Subject: [PATCH 5/7] Update Seminar03.cpp --- MySolutions/Seminar03.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MySolutions/Seminar03.cpp b/MySolutions/Seminar03.cpp index a7306fa..7469281 100644 --- a/MySolutions/Seminar03.cpp +++ b/MySolutions/Seminar03.cpp @@ -503,7 +503,7 @@ int main() //} - // Zad_20 (???? ? ????? ???? ?? ??????????? ?????) + // Zad_20 (KODA BACHKA SAMO ZA EDNOCIFRENI CHISLA) /*int n; cin >> n; @@ -581,4 +581,4 @@ int main() cout << "\n"; }*/ -} \ No newline at end of file +} From e60cecf9c4b65ae563fa904f8b998f23e79a9121 Mon Sep 17 00:00:00 2001 From: "Martin K." Date: Sat, 2 Nov 2024 12:28:43 +0200 Subject: [PATCH 6/7] Seminar03 --- MySolutions/Seminar03.cpp | 131 ++++++++++++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 26 deletions(-) diff --git a/MySolutions/Seminar03.cpp b/MySolutions/Seminar03.cpp index a7306fa..d3a07de 100644 --- a/MySolutions/Seminar03.cpp +++ b/MySolutions/Seminar03.cpp @@ -3,32 +3,32 @@ #include using namespace std; -bool isPrime(int num) { - - for (int i = 2; i < num / 2; i++) - { - - if (num % i == 0) { - - return false; - } - } - - return true; -} - -bool isRightTriangle(int a, int b, int c) { - - if ((a + b > c) && (b + c > a) && (a + c > b)) { - - if (pow(a, 2) + pow(b, 2) == pow(c, 2)) { - - return true; - } - } - - return false; -} +//bool isPrime(int num) { +// +// for (int i = 2; i < num / 2; i++) +// { +// +// if (num % i == 0) { +// +// return false; +// } +// } +// +// return true; +//} + +//bool isRightTriangle(int a, int b, int c) { +// +// if ((a + b > c) && (b + c > a) && (a + c > b)) { +// +// if (pow(a, 2) + pow(b, 2) == pow(c, 2)) { +// +// return true; +// } +// } +// +// return false; +//} int main() { @@ -581,4 +581,83 @@ int main() cout << "\n"; }*/ + + // Zad_21 + + + // Zad_22 + + // A) + + //int n; + //cin >> n; + + //int minusCounter = (n * 2) - 1; + //int plusCounter = 1; + + //for (int row = 1; row <= n; row++) + //{ + // int previousNum = row; + + // for (int colm = 1; colm <= n; colm++) + // { + + // if (colm == 1) { + + // cout << row << " "; + + // } + // else { + + // if (colm % 2 == 0) { + + // cout << previousNum + minusCounter << " "; + + // previousNum += minusCounter; + // } + // else + // { + + // cout << previousNum + plusCounter << " "; + + // previousNum += plusCounter; + // } + // } + // } + + // minusCounter -= 2; + // plusCounter += 2; + + // cout << "\n"; + //} + + // B) + + /*int n; + cin >> n; + + for (int row = 1; row <= n; row++) + { + if (row % 2 != 0) { + + for (int left = (row * n) - n + 1; left <= row * n; left++) + { + + cout << left << " "; + } + + cout << "\n"; + } + else { + + for (int right = row * n; right >= (row * n) - n + 1; right--) + { + + cout << right << " "; + } + + cout << "\n"; + } + }*/ + } \ No newline at end of file From e8ef2317e0e618654f50f2e8987dcd608658044e Mon Sep 17 00:00:00 2001 From: "Martin K." Date: Sat, 2 Nov 2024 17:51:07 +0200 Subject: [PATCH 7/7] Seminar04 --- MySolutions/Seminar03.cpp | 2 +- MySolutions/Seminar04.cpp | 539 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 540 insertions(+), 1 deletion(-) create mode 100644 MySolutions/Seminar04.cpp diff --git a/MySolutions/Seminar03.cpp b/MySolutions/Seminar03.cpp index 7f8425a..e53d232 100644 --- a/MySolutions/Seminar03.cpp +++ b/MySolutions/Seminar03.cpp @@ -5,7 +5,7 @@ using namespace std; //bool isPrime(int num) { // -// for (int i = 2; i < num / 2; i++) +// for (int i = 2; i <= num / 2; i++) // { // // if (num % i == 0) { diff --git a/MySolutions/Seminar04.cpp b/MySolutions/Seminar04.cpp new file mode 100644 index 0000000..c442362 --- /dev/null +++ b/MySolutions/Seminar04.cpp @@ -0,0 +1,539 @@ +// MK_Project.cpp : This file contains the 'main' function. Program execution begins and ends there. + +#include +using namespace std; + +//bool isPrime(int num) { +// +// for (int i = 2; i <= num / 2; i++) +// { +// +// if (num % i == 0) { +// +// return false; +// } +// } +// +// return true; +//} +// +//int sum(int a, int b) { +// +// return a + b; +//} +// +//bool isEven(int num) { +// +// return num % 2 == 0; +//} +// +//bool isPositive(int num) { +// +// return num > 0; +//} +// +//bool isNegative(int num) { +// +// return num < 0; +//} +// +//int abs(int num) { +// +// if (isNegative(num)) { +// +// return num * -1; +// } +// +// return num; +//} +// +//double fabs(double num) { +// +// if (isNegative(num)) { +// +// return num * -1; +// } +// +// return num; +//} +// +//void print(char S, int N) { +// +// for (int i = 1; i <= N; i++) +// { +// cout << S; +// } +//} +// +//bool checkSymbol(char S) { +// +// return (S >= 65 && S <= 90) || (S >= 97 && S <= 122); +//} +// +//bool isCapitalLetter(char S) { +// +// return checkSymbol(S) && (S >= 65 && S <= 90); +//} +// +//char to_lower(char ch) { +// +// if (isCapitalLetter(ch)) { +// +// return ch + 32; +// } +// +// return ch; +//} +// +//char to_upper(char ch) { +// +// if (!isCapitalLetter(ch)) { +// +// return ch - 32; +// } +// +// return ch; +//} +// +//int numLenght(int n) { +// +// int counter = 0; +// +// while (n != 0) { +// +// counter++; +// n /= 10; +// } +// +// return counter; +//} +// +//int numLooker(int n, int k) { +// +// int lenght = numLenght(n); +// int num = -1; +// +// if (k > lenght || k < 1) { +// +// return 0; +// } +// +// for (int i = lenght; i >= k; i--) +// { +// num = n % 10; +// +// n /= 10; +// } +// +// return num; +//} +// +//void isSquareRoot(int n) { +// +// for (int i = 1; i <= n / 2; i++) +// { +// if (i * i == n) { +// +// cout << n << " - yes (" << i << "^2)"; +// return; +// } +// } +// +// cout << n << " - no " << "(?^2)"; +//} +// +//int NOK(int a, int b, int c) { +// +// int nok = 1; +// int maxNum = ((a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c)); +// +// while (a != 1 && b != 1 && c != 1) { +// +// for (int i = 2; i <= maxNum; i++) +// { +// +// bool devided = false; +// +// if (!isPrime(i)) { +// +// continue; +// } +// +// if (a % i == 0) { +// +// a /= i; +// devided = true; +// } +// +// if (b % i == 0) { +// +// b /= i; +// devided = true; +// } +// +// if (c % i == 0) { +// +// c /= i; +// devided = true; +// } +// +// if (devided) { +// +// nok *= i; +// i--; +// } +// } +// } +// +// return nok; +//} +// +//bool inBetween(int start, int end, int num) { +// +// return (num >= start) && (num <= end); +//} +// +//int askUser(int from, int to) { +// +// int n; +// cin >> n; +// +// while (!inBetween(from, to, n)) { +// +// cin >> n; +// } +// +// return n; +//} +// +//int myPow(int num, unsigned N) { +// +// int powNum = 1; +// +// for (int i = 1; i <= N; i++) +// { +// powNum *= num; +// } +// +// return powNum; +//} +// +//int concat(int first, int second) { +// +// unsigned lenght = numLenght(second); +// +// return (first * myPow(10, lenght)) + second; +//} +// +//int NOD(int a, int b, int c, int d) { +// +// int maxNum = max(max(a, b), max(c, d)); +// +// for (int i = maxNum; i >= 1; i--) +// { +// if ((a % i == 0) && (b % i == 0) +// && (c % i == 0) && (d % i == 0)) { +// +// return i; +// } +// } +//} +// +//bool isNumPowerOfTwo(int num) { +// +// for (int i = 1; i <= num; i++) +// { +// if (myPow(2, i) == num) { +// +// return true; +// } +// } +// +// return false; +//} +// +//int closestToPowerOfTwo(int num) { +// +// int answer1 = 0; +// int answer2 = 0; +// +// for (int i1 = num; i1 >= 100; i1--) +// { +// if (isNumPowerOfTwo(i1)) { +// +// answer1 = i1; +// break; +// } +// } +// +// for (int i2 = num; i2 <= 100000; i2++) +// { +// if (isNumPowerOfTwo(i2)) { +// +// answer2 = i2; +// break; +// } +// } +// +// if (answer1 == 0) { +// +// return answer2; +// } +// else if (answer2 == 0) { +// +// return answer1; +// } +// +// answer1 -= num; +// answer2 -= num; +// +// return (abs(answer1) < abs(answer2)) ? answer1 + num : answer2 + num; +//} +// +//void allPrimesTo(int n) { +// +// for (int i = 1; i <= n; i++) +// { +// if (isPrime(i)) { +// +// cout << i << " "; +// } +// } +//} +// +//bool isnumTwoPrimeNumber(int n) { +// +// for (int i1 = 1; i1 <= n; i1++) +// { +// for (int i2 = 1; i2 <= n; i2++) +// { +// if (isPrime(i1) && isPrime(i2) && (i1 + i2 == n)) { +// +// return true; +// } +// } +// } +// +// return false; +//} +// +//long sumOfNumbers(long n) { +// +// long sum = 0; +// +// while (n != 0) { +// +// sum += n % 10; +// n /= 10; +// } +// +// return sum; +//} +// +//void factorization(int num) { +// +// if (num == 1) { +// +// cout << 1; +// return; +// } +// +// for (int i = 2; i <= num; i++) +// { +// if (isPrime(i) && num % i == 0) { +// +// cout << i; +// +// num /= i; +// +// if (num == 1) { +// +// return; +// } +// else { +// +// cout << "."; +// } +// +// i--; +// } +// } +//} +// +//int sortNum(int num) { +// +// int number = 0; +// int plusCounter = 0; +// +// for (int i1 = 9; i1 >= 0; i1--) +// { +// int counter = 0; +// +// for (int i2 = 1; i2 <= numLenght(num); i2++) +// { +// if (numLooker(num, i2) == i1) { +// +// counter++; +// } +// } +// +// for (int i3 = 1; i3 <= counter; i3++) +// { +// number += i1 * myPow(10, plusCounter); +// plusCounter++; +// } +// } +// +// return number; +//} + +int main() +{ + // Zad_1 + + // << sum(13, 21); + + + // Zad_2 + + //cout << isEven(69); + + + // Zad_3 + + //cout << isPositive(10); + //cout << isNegative(-10); + + + // Zad_4 + + //cout << abs(-10); + //cout << fabs(-10.55); + + + // Zad_5 + + //print('$', 20); + + + // Zad_6 + + //cout << isCapitalLetter('G'); + + + // Zad_7 + + //cout << to_lower('G'); + //cout << to_upper('g'); + + + // Zad_8 + + //cout << numLenght(1022402952); + + + // Zad_9 + + //cout << numLooker(98765432, 3); + + + // Zad_10 + + //isSquareRoot(100); + + + // Zad_12 + + //cout << NOK(12, 18, 6); + + + // Zad_13 + + /*cout << concat(123, 456);*/ + + + // Zad_14 + + /*cout << askUser(10, 50);* + + + // Zad_15 + + /*cout << myPow(10, 5);*/ + + + // Zad_16 + + //int a, b, c, d; + + + //cout << "A = "; + //cin >> a; + + //cout << "B = "; + //cin >> b; + + //cout << "C = "; + //cin >> c; + + //cout << "D = "; + //cin >> d; + + + //cout << "NOD = " << NOD(a, b, c, d); + + // Zad_17 + + //int n; + //cin >> n; + + //while (!inBetween(100, 100000, n)) { + // cin >> n; + //} + + //cout << closestToPowerOfTwo(n); + + + // Zad_18 + + /*allPrimesTo(100); + cout << isnumTwoPrimeNumber(100);*/ + + + // Zad_19 + + /*long n; + cin >> n; + + cout << sumOfNumbers(n) << "\n"; + + long sum = 0; + + while (n != 0) { + + sum += n % 10; + n /= 10; + + if ((n == 0) && (sum > 9)) { + + n = sum; + sum = 0; + } + } + + cout << sum << "\n";*/ + + + // Zad_20 + + //factorization(31668); + + + // Zad_21 + + //int n; + //cin >> n; + + //cout << sortNum(n); + +} \ No newline at end of file