-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull request | Martin Kirchev | Seminar 1, 2, 3, 4 #19
base: main
Are you sure you want to change the base?
Conversation
//cin >> x1 >> y1; | ||
//cin >> x2 >> y2; | ||
|
||
//double distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не използвай pow
//char symbol; | ||
//cin >> symbol; | ||
|
||
//if ((symbol >= 65 && symbol <= 90) || (symbol >= 97 && symbol <= 122)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
//if ((symbol >= 65 && symbol <= 90) || (symbol >= 97 && symbol <= 122)) { | ||
|
||
// if (islower(symbol)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
провери го ръчно, не използва вградените функции.
|
||
//}else if (number == 9) { | ||
|
||
// cout << "IX"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
със switch са по-малко редове в случая и става по-четимо
//cin >> num1 >> num2 >> num3; | ||
|
||
//int sum = num1 + num2 + num3; | ||
//int maxNum = max(max(num1, num2), num3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не може max и min,измисли друг начин да се провери
//int sum = num1 + num2 + num3; | ||
//int maxNum = max(max(num1, num2), num3); | ||
//int minNum = min(min(num1, num2), num3); | ||
//int middle = sum - maxNum - minNum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не е такова условието
// if (day > 30) { | ||
|
||
// day = 1; | ||
// month = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не трябва ли пак да увеличиш месеца ?
MySolutions/Seminar03.cpp
Outdated
#include <iostream> | ||
using namespace std; | ||
|
||
bool isPrime(int num) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
на този етап не можеше да се използват функции.
MySolutions/Seminar03.cpp
Outdated
|
||
bool isPrime(int num) { | ||
|
||
for (int i = 2; i < num / 2; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можеш да ползваш sqrt(num), за да намалиш още броя на стъпките, тъй като ако дадено число не е кратно на друго няма да е кратно и на квадрата му
//{ | ||
// if (isPrime(n)) { | ||
|
||
// sum += n; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Двуцифрено число - няма го
Просто число - има го
break; | ||
} | ||
|
||
if (isPrime(num) && (n % num != 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не е нужно num да е просто, за да е валидно. Взаимно прости са числа, чиито НОД е 1. На семинар са преподадени методи за намиране на НОД.
|
||
for (int row = 1; row <= n; row++) | ||
{ | ||
if (row % 2 != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вярвам ти, че работи :)
} | ||
else { | ||
|
||
for (int right = row * n; right >= (row * n) - n + 1; right--) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(row * n) - n + 1
Смятай го извън условието на for-a, така на всяка итерация ще се смята всеки път, което е излишно. Това важи за всеки случай.
// | ||
//double fabs(double num) { | ||
// | ||
// if (isNegative(num)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNegative приема int, а ти му подаваш double. Също така това не е коректен начин за сравняване на double.
// | ||
//bool checkSymbol(char S) { | ||
// | ||
// return (S >= 65 && S <= 90) || (S >= 97 && S <= 122); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Използвай 'A','Z'..., а не просто цифрите. Така се задължаваш да ги помниш наизуст, което е излишно като знаеш че char може да се конвентира имплицитно към int
//} | ||
// | ||
//int numLenght(int n) { | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Колко е дължината на 0 ?
// { | ||
// | ||
// bool devided = false; | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Това да е просто как пречи ?
// | ||
// int maxNum = max(max(a, b), max(c, d)); | ||
// | ||
// for (int i = maxNum; i >= 1; i--) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// | ||
// for (int i = 1; i <= n; i++) | ||
// { | ||
// if (isPrime(i)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
sum += n % 10; | ||
n /= 10; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вкарай го във функцията или напиши друго за четимост
Много добра работа! |
Написал съм всички задачи (без 21 зад от 3-ти семинар, но и тя ще бъде решена в бъдеще) до 4-ти семинар включително и търся обратна връзка как съм се справил. Задачите се намират в папката MySolution.