Country code + mobile phone number, mobile phone number

Source: Internet
Author: User

Country code + mobile phone number, mobile phone number
The standard format of Chinese Mainland carrier mobile phone numbers is: country code + mobile phone number, for example: 8613912345678. Features:

1. Length 13;
2. Start with 86 country codes;
3. Each digit of the mobile phone number is a number.
4. For example, the following mobile phone numbers are qualified: + 86-13957177889, 8613957177889, + 8613957177889, + 86-139-5717-7889, and 86-13957177889.

Please implement the function of determining the validity of the mobile phone number (Note: The examinee does not need to pay attention to the authenticity of the mobile phone number, that is, the mobile phone number such as 86123123456789, we also think it is legal). Requirements:

1. If the mobile phone number is qualified, return 0;
2. If the phone number length is invalid, 1 is returned;
3. If the mobile phone number contains non-numeric characters, 2 is returned;
4. If the phone number does not start with 86, 3 is returned;
5. In other cases, return 4.

Note: Except for successful cases, the priority of the above legitimacy judgment is reduced once. That is to say, if the length is determined invalid, 1 is returned directly, and no other legitimacy judgment is required.

<Span style = "font-family: KaiTi_GB2312;"> code: </span> # include <stdio. h> # include <string. h> bool BE (char str []) // starts with '+' and returns 1 {if (str [0] = '+') return 1; return 0 ;} bool _ 86 (char str [], int len) // whether to start with 86 {if (BE (str )) {if (str [1] = '8' & str [2] = '6') return 1; elsereturn 0 ;} else {if (str [0] = '8' & str [1] = '6') return 1; elsereturn 0 ;}} int Len (char str [], int len) {int I, k = 0; for (I = 0; I <len; ++ I) {if (str [I]> = '0' & str [I] <= '9 ') K ++;} return k;} bool _ FSZ (char str [], int len) // returns 1; {int I; if (BE (str) for (I = 1; I <len; ++ I) {if (str [I]! = '-'&&! (Str [I]> = '0' & str [I] <= '9') return 1 ;}else {for (I = 0; I <len; ++ I) {if (str [I]! = '-'&&! (Str [I]> = '0' & str [I] <= '9') return 1 ;}} return 0 ;} int MAIN () {char str [20]; gets (str); int len = strlen (str); switch (len) {case 13: if (_ 86 (str, len )) return 0; // else break; case 14: if (_ 86 (str, len) if (BE (str) | str [2] = '-') return 0; case 15: if (_ 86 (str, len) if (BE (str) & str [3] = '-') return 0; case 17: if (_ 86 (str, len) if (BE (str) & str [3] = '-' & str [7] = '-' & str [12] = '-') return 0 ;} if (Len (str, len )! = 13) // return 1; else {if (_ FSZ (str, len) return 2; else {if (_ 86 (str, len )) return 4; elsereturn 3 ;}} int main () {while (1) printf ("% d \ n", MAIN (); return 0 ;}


The mobile phone number must contain your country code and access number, for example, 63 + 918 + 9999999.

What you wrote: 63 + 918 + 9999999

In front of this 63 is the international area code of the Philippines, and in China it is 86. When making a call, add two zeros to the front, that is, to call 0086, if you fill in your words, you can fill in 86. The 918 is a mobile phone, which means the same as the 138 and 139 mobile phones. You just need to fill in your number segment, the last 9999999 is the mobile phone number. You just need to fill in the ones after 13X.

What is the length of a Chinese mobile user number (including a country code?

A total of 13 digits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.