-
Notifications
You must be signed in to change notification settings - Fork 2
1HwKobzystyiMaksym #40
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #include <cmath> | ||
| #include <cstring> | ||
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| int main() { | ||
| double a; | ||
| double b; | ||
| double c; | ||
| double x; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. старайтесь обьявлять переменные по мере их использования. Т.е. не обьязательно все сразу обьявлять вначале функции. |
||
| std::cout << "Enter a: "; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем вы вначале тогда подключали |
||
| std::cin >> a; | ||
| std::cout << "Enter b: "; | ||
| std::cin >> b; | ||
| std::cout << "Enter c: "; | ||
| std::cin >> c; | ||
| if ((b * b - 4 * a * c) >= 0) // If >=0 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. у вас выражение |
||
| { | ||
| x = (-1 * b + sqrt(b * b - 4 * a * c)) / (2 * a); | ||
| std::cout << "1st root " << x << std::endl; | ||
| x = (-1 * b - sqrt(b * b - 4 * a * c)) / (2 * a); | ||
| std::cout << "2nd root " << x << std::endl; | ||
| } else { | ||
| std::cout << "Less 0" << endl; | ||
| } | ||
|
|
||
| int value; | ||
| cin >> value; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. можно еще попробовать |
||
| return 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.
это лишнее, понимаю что в качестве примеров для дз это ок, но для будущего старайтесь такие вещи просто избегать. конструкция типа
using namespace std;может привести к неприятным сюрпризам