Cell phone number legality judgment
Problem Description: The standard format of mobile phone number of Chinese mainland operators is:
Country code + mobile phone number, for example: 8613912345678.
Features are as follows: 1, 13 bits in length;
2, with 86 of the country code starts;
3, mobile phone number of each person is a number. Please implement the function of cell phone number legality judgment
(Note: Candidates do not need to pay attention to the authenticity of mobile phone numbers
In other words, such as 86123123456789 of the mobile phone number, we also think it is legal),
Requirements: 1) If the mobile phone number is valid, return 0;
2) If the phone number is not valid, return 1
3) If the phone number contains non-numeric characters, return 2;
4) If the mobile phone number does not begin with 86, return 3;
"Note" In addition to the success of the case, the above other legal judgment priority reduced. Other words
If you determine the length is not legal, directly return 1, do not need to do other legal judgment.
Required implementation function: int s int verifymsisdn (char* inmsisdn)
"Input" char* inmsisdn, which represents the input mobile number string.
"Output" none
The result of the "return" judgment, type int.
Example
Input: inmsisdn = "869123456789"
Output: None
Returns: 1
Input: inmsisdn = "88139123456789"
Output: None
Returns: 3
#include <string>using namespacestd;intVERIFYMSISDN (Char*inmsisdn) {unsigned Len=strlen (INMSISDN); if(Len! = -) return 1; for(Unsigned i=0; i<len;i++) { if(inmsisdn[i]<'0'|| Inmsisdn[i]>'9') return 2; } if(inmsisdn[0]!='8'|| inmsisdn[1]!='6') return 3; return 0;}