In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you based on the Luhn algorithm format to verify whether the bank card number entered by the user is correct, I hope you will gain something after reading this article, let's discuss it together!
IOS Code:
/ * * @ param cardNo bank card number * * @ return * / + (BOOL) checkCardNo: (NSString*) cardNo {int oddsum = 0; / / odd summation int evensum = 0; / / even summation int allsum = 0; int cardNoLength = (int) [cardNo length]; int lastNum = [[cardNo substringFromIndex:cardNoLength-1] intValue]; cardNo = [cardNo substringToIndex:cardNoLength-1] For (int I = cardNoLength-1)) {NSString * tmpString = [cardNo substringWithRange:NSMakeRange (imuri 1,1)]; int tmpVal = [tmpString intValue]; if (cardNoLength% 2 = = 1) {if ((I% 2) = = 0) {tmpVal * = 2; if (tmpVal > = 10) tmpVal-= 9; evensum + = tmpVal;} else {oddsum + = tmpVal }} else {if ((I% 2) = = 1) {tmpVal * = 2; if (tmpVal > = 10) tmpVal-= 9; evensum + = tmpVal;} else {oddsum + = tmpVal;}} allsum = oddsum + evensum; allsum + = lastNum; if ((allsum% 10) = = 0) return YES; else return NO;}
Androd Code:
/ * matching Luhn algorithm: it can be used to detect the bank card number * @ param cardNo * @ return * / public static boolean matchLuhn (String cardNo) {int [] cardNoArr = new int [cardNo.length ()]; for (int isidentin I = 0transferiMusure 2) {cardNoArr [I]
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.