Created
September 27, 2022 23:27
-
-
Save modos/08735e47e154beb3099404d78268a991 to your computer and use it in GitHub Desktop.
Bank Card Verifier
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 characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
while(true) | |
{ | |
string div1, div2, div3, div4; | |
cin >> div1; | |
if(div1[0] == '0') | |
break; | |
cin >> div2 >> div3 >> div4; | |
string id = div1 + div2 + div3 + div4; | |
int oddsSum = 0; | |
for(int i=0; i<16; i++) | |
{ | |
if((i+1) % 2 == 1) | |
{ | |
int adad = (id[i] - '0') *2; | |
if(adad > 9) | |
adad -= 9; | |
oddsSum += adad; | |
} | |
else | |
{ | |
oddsSum += id[i] - '0'; | |
} | |
} | |
if(oddsSum % 10 == 0) | |
cout << "Yes" << endl; | |
else | |
cout << "No" << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment