搞笑题,一开始因为把年月日转为了int导致个位数前面少了0而WA。后面改成生日直接提取输出就OK了。
#include <stdio.h>
void main()
{
int num=0;
scanf("%d",&num);
int i=0;
while(i<num)
{
char str[20];
scanf("%s",str);
int nProvince = (str[0]-48)*10 + str[1]-48;
char *sProvince;
if(nProvince == 33)
sProvince = "Zhejiang";
else if (nProvince == 11)
sProvince = "Beijing";
else if (nProvince == 71)
sProvince = "Taiwan";
else if (nProvince == 81)
sProvince = "Hong Kong";
else if (nProvince == 82)
sProvince = "Macao";
else if (nProvince == 54)
sProvince = "Tibet";
else if (nProvince == 21)
sProvince = "Liaoning";
else if (nProvince == 31)
sProvince = "Shanghai";
printf("He/She is from %s,and his/her birthday is on ",sProvince);
printf("%c%c,%c%c,",str[10],str[11],str[12],str[13]);
printf("%c%c%c%c based on the table.\n",str[6],str[7],str[8],str[9]);
i++;
}
}