Created
September 6, 2024 21:42
-
-
Save parpok/e986ddb05670bfc4e878a1174b2cd6d3 to your computer and use it in GitHub Desktop.
Revisions
-
parpok created this gist
Sep 6, 2024 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #include <iostream> int main() { std::string CardNumba; int CardNumbers[16]; int SecondCardNumbers[8]; int fullCardEq{}; std::cout << "Gib card numba\n"; std::cin >> CardNumba; if (CardNumba.length() != 16) { std::cout << "Card number must be 16 digits long!\n"; return 1; } for (int i = 0; i < CardNumba.length(); i++) { CardNumbers[i] = CardNumba[i] - '0'; } for (int i = 0; i < 16; i++) { int currentDigit = CardNumbers[i]; if (i % 2 == 0) { currentDigit *= 2; if (currentDigit > 9) { currentDigit -= 9; } } fullCardEq += currentDigit; } if (fullCardEq % 10 == 0) { std::cout << "Valid card \n"; } else { std::cout << "Bad card \n"; } return 0; }