For example in pset1 hacker edition program asks user to input the number of credit card. Imagine that a digits are: 1234567890 So can anyone tell me does it possible to convert this number into elements of array {1,2,3,4,5,6,7,8,9,0} and if it possible than how?
in my code it looks like this:
//askin the user to input number
long long cc_num; //here is another question do i need to declare cc_num equals zero?
do{
printf("number:);
cc_num = GetLongLong();
}
while (cc_num < 10 && cc_num > 10); //we assume that number always be 10 digits
//so here i want to declare an array using the digits from cc_num like elements of an array
int array[11];
for (int i = 0, n = strlen(cc_num); i < n; i++)
{
array[i] = ???
for (i = 9; i > 0; i -= 2) //here i want to start counting from second-to-last element
{
//multiply each second element by 2
//sum multiplyed elements = a
}
for (i = 10; i >= 0; i -= 2) //here i want to start counting from last element to get result of sum non-multiplyed elements
{
//sum non-multiplyed elements = b
}
//sum multiplyed and non-multiplyed (a + b)
}
i have already spent 2 days and 2 nights solving this problem...heeeelp me
(cc_num < 10 && cc_num > 10)
is always false because ifcc_num
is < 10, the left sub-condition is true and the other is false and if it's > 10, the right sub-condition is true and the other is false and if it's 10, the both are false.cc_num != 10
! ;)