Skip to content

Added implementation of lucky tickets#4

Open
cutenti wants to merge 1 commit intomainfrom
LuckyTikets
Open

Added implementation of lucky tickets#4
cutenti wants to merge 1 commit intomainfrom
LuckyTikets

Conversation

@cutenti
Copy link
Owner

@cutenti cutenti commented Oct 20, 2025

Моё решение задачи про счастливые билетики.

@cutenti cutenti requested a review from chernishev October 20, 2025 20:43
Copy link
Collaborator

Choose a reason for hiding this comment

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

бинарные файлы не коммитим


int main(void)
{
printf("Введите число от 0 до 27:\t");
Copy link
Collaborator

Choose a reason for hiding this comment

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

это не "подсчётом числа билетов с заданной суммой трёх цифр"

@cutenti cutenti force-pushed the LuckyTikets branch 2 times, most recently from 0d8e48a to ea1e13c Compare December 11, 2025 16:16
for (int z1 = 0; z1 <= 9; z1++) { // первая цифра
for (int z2 = 0; z2 <= 9; z2++) { // вторая цифра
for (int z3 = 0; z3 <= 9; z3++) { // третья цифра
if ((z1 <= z2) && (z2 <= z3)) { // чтобы не было повторов (мы же сочетания считаем)
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 summ = 1; summ <= 27; summ++) { // а теперь не берем нулевую сумму
fullCount += oneSummCount[summ] * oneSummCount[summ];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Это можно сделать сразу при подсчёте сумм. Не надо делать лишний проход.

Copy link
Owner Author

Choose a reason for hiding this comment

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

не совсем понимаю как, если мы сначала добавляем всё, а потом возводи в квадрат

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.

3 participants