#include
#include
#include
using namespace std;
void printCN(string cardCN,int size);
int main()
{
string cardInput = "";
constint size = 16; // Number of digits the card number have
int card[size]; //This array stores card number
int sum = 0;
int oddSum = 0, evenSum;
cout < "enter="" credit="" card="" number:="">
cin >> cardInput;
for (int counter = 0; counter < cardinput.size();="" counter++)="" card[counter]="cardInput[counter]-">
//Luhn Alogrithm
for (int counter = size - 1; counter >=0; counter--)
{
int placeholder;
int x = card[counter];
if (counter % 2 ==0)
{
placeholder = x * 2;
if (placeholder > 9) placeholder = placeholder - 9;
evenSum += placeholder;
}
else
{
placeholder = x;
oddSum += placeholder;
}
}
sum = evenSum + oddSum;
cout < "even="" sum="" is="" :="" "=""><>
cout < "="" \n="" odd="" sum="" is="" :="" "=""><>
cout < "\n="" total="" sum="" is="" :="" "="">< sum=""><>
if (sum % 10 == 0) {
cout <>
printCN(cardInput, size);
cout < "card="" is="">
}
else {
cout <>
printCN(cardInput, size);
cout < "card="" is="">
}
//4000000000002829
//4000001234567899
return EXIT_SUCCESS;
}
void printCN(string cardInput, int size)
{
if (cardInput[0]=='4')
{
cout < "="" visa="">
}
elseif (cardInput[0] == '6')
{
cout < "="" master="">
}
else
{
cout < "="" unknown="" brand="">
}
}