給出一個身份證號,輸出對應(yīng)地區(qū)以及出生年月
330000199602145632
330000 19960214 5632
1.將這個數(shù)組分離然后存儲到數(shù)組,再轉(zhuǎn)成字符串,然后去比對對應(yīng)的地名
2.多組輸入,當(dāng)時每次輸入得到的都是相同的結(jié)果,執(zhí)行完一次需要將數(shù)組計數(shù)變量置0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *getCountry(char *country)
{
if(strcmp(country,"333000")==0)
return "Beijing";
else if(strcmp(country,"111000")==0)
return "Taiwan";
return 0;
}
int main()
{
long long input;
int n;
int i;
int country[1000];
int con1[1000];
char country1[1000];
int j=0,k=0;
scanf("%d",&n);
while(n--)
{
scanf("%lld",&input);
while(input!=0)
{
country[j++] = input % 10;
input /= 10;
}
for(i=j-1; i>=0; i--)
{
con1[k++] = country[i];
}
for(i=0; i<6; i++)
{
country1[i] = con1[i] + '0';
}
country1[6] = '\0';
//printf("%s\n",country1);
printf("%s\n",getCountry(country1));
j = 0;
k = 0;
}
return 0;
}