1. 程式人生 > >身份證判斷年齡及性別

身份證判斷年齡及性別

#include<stdio.h>
int main()
{
char IDNumber[19];
int year=0,i;
printf("please input your ID Number:\n");
scanf("%s",IDNumber);
for(i=6;i<=9;i++)
year=10*year+(IDNumber[i]-'0');
printf("%d\n",2018-year);
if((IDNumber[16]-'0')%2==1)
printf("yes male\n");
else
printf("no\nfemale\n");
return 0;
}