- #include<stdio.h>
- #include<stdlib.h>
- #define LEN \\
- (int)sizeof (country_code)/sizeof (country_code[0])
- struct dialing_code{
- char *english_name;
- char *chinese_name;
- int code;
- };
- const struct dialing_code country_code[]=
- {{"Argentina","阿根廷", 54},{"Bangladesh","孟加拉国", 880},
- {"Brazil","巴西", 55},{"Burma(Myanmar)","缅甸联邦", 95},
- {"China","中国", 86},{"Colombia","哥伦比亚", 57},
- {"Congo,Dem.Rep.of","刚果(金)",243},{"Egypt","诶及", 20},
- {"Ethiopia","埃塞俄比亚", 251},{"France","法兰西共和国", 33},
- {"Germany","德国", 49},{"India","印度", 91},
- {"Indonesia","印度尼西亚", 62},{"Iran","伊朗", 98},
- {"Italy","意大利", 39},{"Japan","日本", 81},
- {"Mexico","墨西哥", 52},{"Nigeria","尼日尔", 234},
- {"Pakistan","巴基斯坦", 92},{"Philippines","菲律宾", 63},
- {"Poland","波兰", 48},{"Russia","俄罗斯联邦", 7},
- {"South Africa","南非", 27},{"Korea","韩国", 82},
- {"Spain","西班牙", 34},{"Sudan","苏丹共和国", 249},
- {"Thailand","泰国", 66},{"Turkey","土耳其共和国", 90},
- {"Ukraine","乌克兰", 380},{"United Kingdom","联合王国", 44},
- {"United States","美利坚共和国", 1},{"Vietnam","越南", 84}};
- int main(void)
- {
- int code,i;
- printf("请输入国际电话区号:");
- scanf("+%d",&code);
- for(i=0;i<LEN;i++){
- if(code==country_code[i].code){
- printf("国际区号+%d的所属地为%s(%s).\\n",country_code[i].code,
- country_code[i].chinese_name,country_code[i].english_name);
- exit(0);
- }
- }
- printf("未找到此区号所属地 或 区号格式不正确(+国际区号).");
- exit(0);
- }
- //该片段来自于http://www.codesnippet.cn/detail/290820135440.html
来源: http://www.codesnippet.cn/detail/290820135440.html