Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions HomeWork2/2Hw2exKobzystyiMaksym
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;
Copy link
Owner

Choose a reason for hiding this comment

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

так а если number содержит больше чем 6ть цифр?

int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
Copy link
Owner

Choose a reason for hiding this comment

The 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;
Copy link
Owner

Choose a reason for hiding this comment

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

можно завести одну переменную для левой части суммы и другую переменную для правой части

long long left_side = number % 10;
left_side += (number / 10) % 10;
left_side += (number / 100) % 10;

long long right_side = (number / 1000) % 10;
right_side += (number / 10000) % 10;
right_side += (number / 100000) % 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;

int value;
cin >> value;

return 0;
}
24 changes: 24 additions & 0 deletions HomeWork2/2HwKobzystyiMaksym
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;
Copy link
Owner

Choose a reason for hiding this comment

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

зачем заливать один и тот же код?


int value;
cin >> value;

return 0;
}
26 changes: 26 additions & 0 deletions HomeWork2/2HwKobzystyiMaksymm
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;
}
Copy link
Owner

Choose a reason for hiding this comment

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

вообще не понял что означает этот ваш код
напишите какое то описание вверху. Я о том что когда запускаешь ваш код не сразу очевидно, что делает ваш код для пользователя


int value;
cin >> value;

return 0;
}