From 2c791977644937ce4eac1b3a82397a2b6ca0856d Mon Sep 17 00:00:00 2001 From: Misha Date: Tue, 30 Sep 2025 19:52:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20lu?= =?UTF-8?q?cky=5Fnumber.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lucky_number.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 lucky_number.cpp diff --git a/lucky_number.cpp b/lucky_number.cpp deleted file mode 100644 index 319d331..0000000 --- a/lucky_number.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -using namespace std; - -int main() { - int number; - - cout << "Enter a 6-digit number: "; - cin >> number; - - // Check if the number is 6-digit (from 100000 to 999999) - if (number < 100000 || number > 999999) { - cout << "Error! Please enter exactly a 6-digit number (from 100000 to 999999)" << endl; - return 1; - } - - // Extract digits separately - int digit1 = number / 100000; // first digit - int digit2 = (number / 10000) % 10; // second digit - int digit3 = (number / 1000) % 10; // third digit - int digit4 = (number / 100) % 10; // fourth digit - int digit5 = (number / 10) % 10; // fifth digit - int digit6 = number % 10; // sixth digit - - // Calculate sums - int sum_first_three = digit1 + digit2 + digit3; - int sum_last_three = digit4 + digit5 + digit6; - - // Check if lucky - if (sum_first_three == sum_last_three) { - cout << "Congratulations! Number " << number << " is lucky!" << endl; - cout << "Sum of first three digits: " << sum_first_three << endl; - cout << "Sum of last three digits: " << sum_last_three << endl; - } else { - cout << "Number " << number << " is not lucky." << endl; - cout << "Sum of first three digits: " << sum_first_three << endl; - cout << "Sum of last three digits: " << sum_last_three << endl; - } - - return 0; -}