1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
| #include <iostream> #include <map> #include <string>
std::map<std::string, std::string> loadCountryPrefixRules() { std::map<std::string, std::string> countryPrefixRules; countryPrefixRules["B"] = "中国"; return countryPrefixRules; }
std::map<char, std::string> loadStationTypeRules() { std::map<char, std::string> stationTypeRules; stationTypeRules['A'] = "个人业余电台(一级)"; stationTypeRules['D'] = "个人业余电台(二级)"; stationTypeRules['E'] = "个人业余电台(二级)"; stationTypeRules['G'] = "个人业余电台(三级、四级、五级(收信台))"; stationTypeRules['H'] = "个人业余电台(三级、四级、五级(收信台))"; stationTypeRules['I'] = "个人业余电台(三级、四级、五级(收信台))"; stationTypeRules['J'] = "业余信标台"; stationTypeRules['L'] = "外籍及香港、澳门、台湾地区人员在中国内地设置的业余电台"; stationTypeRules['R'] = "业余中继台"; stationTypeRules['T'] = "特设业余电台"; stationTypeRules['Y'] = "集体业余电台"; return stationTypeRules; }
std::map<char, std::map<std::string, std::pair<std::string, std::string> > > loadRegionProvinceRules() { std::map<char, std::map<std::string, std::pair<std::string, std::string> > > regionProvinceRules;
regionProvinceRules['1'] = { {"北京", {"AA", "XZZ"}} };
regionProvinceRules['2'] = { {"黑龙江", {"AA", "HZZ"}}, {"吉林", {"IA", "PZZ"}}, {"辽宁", {"QA", "XZZ"}} };
regionProvinceRules['3'] = { {"天津", {"AA", "FZZ"}}, {"内蒙古", {"GA", "LZZ"}}, {"河北", {"MA", "RZZ"}}, {"山西", {"SA", "XZZ"}} };
regionProvinceRules['4'] = { {"上海", {"AA", "HZZ"}}, {"山东", {"IA", "PZZ"}}, {"江苏", {"QA", "XZZ"}} };
regionProvinceRules['5'] = { {"浙江", {"AA", "HZZ"}}, {"江西", {"IA", "PZZ"}}, {"福建", {"QA", "XZZ"}} };
regionProvinceRules['6'] = { {"安徽", {"AA", "HZZ"}}, {"河南", {"IA", "PZZ"}}, {"湖北", {"QA", "XZZ"}} };
regionProvinceRules['7'] = { {"湖南", {"AA", "HZZ"}}, {"广东", {"IA", "PZZ"}}, {"广西", {"QA", "XZZ"}}, {"海南", {"YA", "ZZZ"}} };
regionProvinceRules['8'] = { {"四川", {"AA", "FZZ"}}, {"重庆", {"GA", "LZZ"}}, {"贵州", {"MA", "RZZ"}}, {"云南", {"SA", "XZZ"}} };
regionProvinceRules['9'] = { {"陕西", {"AA", "FZZ"}}, {"甘肃", {"GA", "LZZ"}}, {"宁夏", {"MA", "RZZ"}}, {"青海", {"SA", "XZZ"}} };
regionProvinceRules['0'] = { {"新疆", {"AA", "FZZ"}}, {"西藏", {"GA", "LZZ"}} };
return regionProvinceRules; }
bool isWithinRange(const std::string &suffix, const std::string &rangeStart, const std::string &rangeEnd) { return suffix >= rangeStart && suffix <= rangeEnd; }
void queryCallSign(const std::string &callSign) { auto countryRules = loadCountryPrefixRules(); auto stationTypeRules = loadStationTypeRules(); auto regionProvinceRules = loadRegionProvinceRules();
if (callSign.length() < 5) { std::cout << "呼号格式不正确" << std::endl; return; }
std::string country = countryRules[callSign.substr(0, 1)];
char stationType = callSign[1]; std::string station = stationTypeRules[stationType];
char region = callSign[2];
std::string suffix = callSign.substr(3, 2);
std::string provinceName = "未知省份"; if (regionProvinceRules.find(region) != regionProvinceRules.end()) { for (const auto &province: regionProvinceRules[region]) { if (isWithinRange(suffix, province.second.first, province.second.second)) { provinceName = province.first; break; } } } if (stationType == 'J') { char suffix1 = callSign[3]; if (suffix1 == 'H' || suffix1 == 'V' || suffix1 == 'U') { station = "HF、VHF、UHV频段信标台"; } else if (suffix1 == 'D') { station = "业余无线电测向专用信标台"; } else if (suffix1 == 'S' && region == '1') { station = "卫星业余电台"; } else if (suffix1 == 'T') { station = "特设业余电台"; } } if (!country.empty() && !station.empty() && provinceName != "未知省份") { std::cout << "呼号: " << callSign << std::endl; std::cout << "国家: " << country << std::endl; std::cout << "电台种类: " << station << std::endl; std::cout << "省份: " << provinceName << std::endl; } else { std::cout << "未找到呼号对应的信息" << std::endl; } }
int main() { std::string callSign; std::cout << "请输入要查询的呼号: "; std::cin >> callSign; std::cout << "\n查询结果如下:\n" << std::endl;
queryCallSign(callSign); system("pause"); return 0; }
|