- 分享
- 0
- 人气
- 0
- 主题
- 26
- 帖子
- 789
- UID
- 189097
- 积分
- 365
- 阅读权限
- 15
- 注册时间
- 2008-12-29
- 最后登录
- 2017-9-25
- 在线时间
- 2965 小时
|
本帖最后由 天空上白云 于 2012-9-19 02:15 PM 编辑
你这题目,谁知道你的 valid 是怎样的判断法 。 。 。
L_Kuan 发表于 2012-9-18 10:11 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 .
答案0 要valid
和最后号码一样也要
例如
6261251”1“
答案“1” 也是valid |
|