字符数组训练:
2月7日下午,国家卫生健康委医政医管局监察专员郭燕红介绍,建立了16个省支援武汉以外地市的一一对口支援关系,以一省包一市的方式全力支持湖北省加强病人的救治工作。请你设计一个对口援建城市查询程序,输入一个省份,输出它的对口援建城市。你可以采用任意的字母形式的输入输出方式,比如“Shan dong”,“shandong”,“Shan_Dong”。
我的程序:
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string city[20]{"shiyan","shennongjia","enshi","xiangyang","yichang","jingmen","suizhou","xiaogan","tianmen","qianjiang","xiantao","jingzhou","huanggang","huangshi","xianning","ezhou"};
string province[20]{"shanxi","tianjin","guizhou","hebei","chongqing","zhejiang","henan","jiangsu","shanghai","beijing","sichuan","hunan","shandong","anhui","jiangxi","guangdong"};
string n;
cin>>n;
for(int i=0;i<16;i++)
if(province[i]==n)
cout<<city[i];
return 0;
}
运行结果:
武汉加油!中国加油!