search

Home  >  Q&A  >  body text

Please tell me how to write this

Verify the 18-digit identity number and determine the gender of the identity owner. The rules for the identity number are:

① The first 17 digits are all composed of numbers, the last digit is a number or the character 'X', and a character ch The

condition for numbers is: ch>='0' && ch<='9';

② If the 17th digit is an odd number, it means the gender is male, and if it is an even number, it means the gender is female.

Input: Enter an 18-digit identity number from the keyboard and save it in the character array Card.

Output: Host gender.

彦骐彦骐1338 days ago1082

reply all(1)I'll reply

  • 清

    2021-04-29 22:42:21

    (substr($idnum, 16, 1) % 2 == 1) ? 'Male' : 'Female';

    reply
    0
  • Cancelreply