Skip to content
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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Martin-Kirchev
Copy link

Написал съм всички задачи (без 21 зад от 3-ти семинар, но и тя ще бъде решена в бъдеще) до 4-ти семинар включително и търся обратна връзка как съм се справил. Задачите се намират в папката MySolution.

//cin >> x1 >> y1;
//cin >> x2 >> y2;

//double distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
Copy link
Collaborator

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)) {
Copy link
Collaborator

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)) {
Copy link
Collaborator

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";
Copy link
Collaborator

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);
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не трябва ли пак да увеличиш месеца ?

#include <iostream>
using namespace std;

bool isPrime(int num) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на този етап не можеше да се използват функции.


bool isPrime(int num) {

for (int i = 2; i < num / 2; i++)
Copy link
Collaborator

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;
Copy link
Collaborator

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)) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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--)
Copy link
Collaborator

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)) {
Copy link
Collaborator

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);
Copy link
Collaborator

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) {
//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Колко е дължината на 0 ?

// {
//
// bool devided = false;
//
Copy link
Collaborator

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--)
Copy link
Collaborator

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)) {
Copy link
Collaborator

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;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вкарай го във функцията или напиши друго за четимост

@DobromirNPeev
Copy link
Collaborator

Написал съм всички задачи (без 21 зад от 3-ти семинар, но и тя ще бъде решена в бъдеще) до 4-ти семинар включително и търся обратна връзка как съм се справил. Задачите се намират в папката MySolution.

Много добра работа!

@Martin-Kirchev Martin-Kirchev changed the title Pull request Pull request | Martin Kirchev | Seminar 1, 2, 3, 4 Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants