给出一个身份证号,输出对应地区以及出生年月
330000199602145632
330000 19960214 5632
1.将这个数组分离然后存储到数组,再转成字符串,然后去比对对应的地名
2.多组输入,当时每次输入得到的都是相同的结果,执行完一次需要将数组计数变量置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;
}
网友评论