-
Notifications
You must be signed in to change notification settings - Fork 2
2 hw kobzystyi maksym #42
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,24 @@ | ||
| #include "iostream" | ||
| using namespace std; | ||
|
|
||
| int main() { | ||
| int number = 0; | ||
| cout << "Enter number of ticket "; | ||
| cin >> number; | ||
| int a = 0, b = 0, c = 0, d = 0, e = 0, f = 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. имена переменных огонь) |
||
| a = number % 10; | ||
| b = (number / 10) % 10; | ||
| c = (number / 100) % 10; | ||
| d = (number / 1000) % 10; | ||
|
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. можно завести одну переменную для левой части суммы и другую переменную для правой части |
||
| e = (number / 10000) % 10; | ||
| f = (number / 100000) % 10; | ||
| if (a + b + c == e + d + f) | ||
| cout << "Yes it's lucky ticket" << endl; | ||
| else | ||
| cout << "Try your luck again :3" << endl; | ||
|
|
||
| int value; | ||
| cin >> value; | ||
|
|
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "iostream" | ||
| using namespace std; | ||
|
|
||
| int main() { | ||
| int number = 0; | ||
| cout << "Enter number of ticket "; | ||
| cin >> number; | ||
| int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; | ||
| a = number % 10; | ||
| b = (number / 10) % 10; | ||
| c = (number / 100) % 10; | ||
| d = (number / 1000) % 10; | ||
| e = (number / 10000) % 10; | ||
| f = (number / 100000) % 10; | ||
| if (a + b + c == e + d + f) | ||
| cout << "Yes it's lucky ticket" << endl; | ||
| else | ||
| cout << "Try your luck again :3" << endl; | ||
|
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. зачем заливать один и тот же код? |
||
|
|
||
| int value; | ||
| cin >> value; | ||
|
|
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| int main() { | ||
| int b1, b2, b3; | ||
| cin >> b1 >> b2 >> b3; | ||
| if ((b1 + b2 + b3) % 3 != 0) { | ||
| cout << "IMPOSSIBLE" << endl; | ||
| } else { | ||
| int average; | ||
| int count = 0; | ||
| average = (b1 + b2 + b3) / 3; | ||
| if (b1 > average) | ||
| count += b1 - average; | ||
| if (b2 > average) | ||
| count += b2 - average; | ||
| if (b3 > average) | ||
| count += b3 - average; | ||
| cout << count << endl; | ||
| } | ||
|
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. вообще не понял что означает этот ваш код |
||
|
|
||
| int value; | ||
| cin >> value; | ||
|
|
||
| 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.
так а если
numberсодержит больше чем 6ть цифр?