if 後少了{}?
if (number1 > 9)
number1=number1-9;
p1= p1 + number1;
ccnumber1=ccnumber1/10;
numb ...
L_Kuan 发表于 2012-9-18 06:19 PM
题目是
write a c++ program that implements this algorithm, this user should supply an 8-digit number, and you should print out whether the number is valid or not .if is not valid, you should print out the value of the check digit that would make the number valid作者: L_Kuan 时间: 2012-9-18 10:11 PM
你这题目,谁知道你的 valid 是怎样的判断法 。 。 。作者: 天空上白云 时间: 2012-9-19 08:42 AM 本帖最后由 天空上白云 于 2012-9-19 02:15 PM 编辑
.starting from the right most digit, form the sum of every other digit. for example, if the credit card number is 4358 9795, then you form the sum 5+7+8+3 =23
.double each of the digits that were not included in the preceding step. add all digit of the resulting numbers. for example. with the number given above , doubling the digits, starting with the to last one, yield 18 18 10 8 . add all digits in these values 1+8+1+8+1+0+8 =27
。add the sums of two preceding steps. if the last digit of the results is 0, the number is valid. in our case, 23+72=50 , so the number is valid
write a c++ program that implements this algorithm. the user should supply 8-digit number, and you should print out wheter the number valid or not . if is not valid , you should print out the value of the check digit that would make the number valid .