user-0 提问: 完全没有思路，恳请高手指点。（C语言）

回复:
user: user-1
content: 对于全球的人在输入时可能会带上音节。举例子， Zürich转化成Zurich，Köln转化成Koln。  做个字符串替换不行吗？当然你得知道都哪些会带上音节？

user: user-0
content: 最主要是不清楚如何把那些欧洲语言上带音节的转化成英文并且识别 恳请指点，感激不尽！ 引用 6 楼 zhao4zhong1 的回复:C:\《算法精解C语言实现》例子代码\examples_pc\include\geodist.h /***************************************************************************** *                                                                            * *  ------------------------------- geodist.h ------------------------------  * *                                                                            * *****************************************************************************/  #ifndef GEODIST_H #define GEODIST_H  /***************************************************************************** *                                                                            * *  Define the radius of the earth in nautical miles.                         * *                                                                            * *****************************************************************************/  #define            EARTH_RADIUS          3440.065  /***************************************************************************** *                                                                            * *  --------------------------- Public Interface ---------------------------  * *                                                                            * *****************************************************************************/  int geodist(double lat1, double lon1, double lat2, double lon2, double *d);  #endif

user: user-0
content: 计算距离的我知道的，主要是前面的不懂呢。恳请指点啊。 引用 6 楼 zhao4zhong1 的回复:C:\《算法精解C语言实现》例子代码\examples_pc\include\geodist.h /***************************************************************************** *                                                                            * *  ------------------------------- geodist.h ------------------------------  * *                                                                            * *****************************************************************************/  #ifndef GEODIST_H #define GEODIST_H  /***************************************************************************** *                                                                            * *  Define the radius of the earth in nautical miles.                         * *                                                                            * *****************************************************************************/  #define            EARTH_RADIUS          3440.065  /***************************************************************************** *                                                                            * *  --------------------------- Public Interface ---------------------------  * *                                                                            * *****************************************************************************/  int geodist(double lat1, double lon1, double lat2, double lon2, double *d);  #endif

user: user-2
content: C:\《算法精解C语言实现》例子代码\examples_pc\include\geodist.h /***************************************************************************** *                                                                            * *  ------------------------------- geodist.h ------------------------------  * *                                                                            * *****************************************************************************/  #ifndef GEODIST_H #define GEODIST_H  /***************************************************************************** *                                                                            * *  Define the radius of the earth in nautical miles.                         * *                                                                            * *****************************************************************************/  #define            EARTH_RADIUS          3440.065  /***************************************************************************** *                                                                            * *  --------------------------- Public Interface ---------------------------  * *                                                                            * *****************************************************************************/  int geodist(double lat1, double lon1, double lat2, double lon2, double *d);  #endif

user: user-2
content: C:\《算法精解C语言实现》例子代码\examples_pc\include\list.h /***************************************************************************** *                                                                            * *  -------------------------------- list.h --------------------------------  * *                                                                            * *****************************************************************************/  #ifndef LIST_H #define LIST_H  #include <stdlib.h>  /***************************************************************************** *                                                                            * *  Define a structure for linked list elements.                              * *                                                                            * *****************************************************************************/  typedef struct ListElmt_ {  void               *data; struct ListElmt_   *next;  } ListElmt;  /***************************************************************************** *                                                                            * *  Define a structure for linked lists.                                      * *                                                                            * *****************************************************************************/  typedef struct List_ {  int                size;  int                (*match)(const void *key1, const void *key2); void               (*destroy)(void *data);  ListElmt           *head; ListElmt           *tail;  } List;  /***************************************************************************** *                                                                            * *  --------------------------- Public Interface ---------------------------  * *                                                                            * *****************************************************************************/  void list_init(List *list, void (*destroy)(void *data));  void list_destroy(List *list);  int list_ins_next(List *list, ListElmt *element, const void *data);  int list_rem_next(List *list, ListElmt *element, void **data);  #define list_size(list) ((list)->size)  #define list_head(list) ((list)->head)  #define list_tail(list) ((list)->tail)  #define list_is_head(list, element) ((element) == (list)->head ? 1 : 0)  #define list_is_tail(element) ((element)->next == NULL ? 1 : 0)  #define list_data(element) ((element)->data)  #define list_next(element) ((element)->next)  #endif

user: user-2
content: C:\《算法精解C语言实现》例子代码\examples_pc\source\geodist.c /***************************************************************************** *                                                                            * *  ------------------------------- geodist.c ------------------------------  * *                                                                            * *****************************************************************************/  #include "geodist.h" #include "geometry.h"  /***************************************************************************** *                                                                            * *  -------------------------------- geodist -------------------------------  * *                                                                            * *****************************************************************************/  int geodist(double lat1, double lon1, double lat2, double lon2, double *d) {  SPoint             p1,                    p2;  /***************************************************************************** *                                                                            * *  Validate the coordinates.                                                 * *                                                                            * *****************************************************************************/  if (lat1 <  -90.0 || lat1 >  90.0 || lat2 <  -90.0 || lat2 >  90.0)    return -1;  if (lon1 < -180.0 || lon1 > 180.0 || lon2 < -180.0 || lon2 > 180.0)    return -1;  /***************************************************************************** *                                                                            * *  Convert each latitude and longitude to spherical coordinates in radians   * *  using the earth's radius for rho.                                         * *                                                                            * *****************************************************************************/  p1.rho = EARTH_RADIUS; p1.theta = -1.0 * DEGTORAD(lon1); p1.phi = (DEGTORAD(-1.0 * lat1)) + DEGTORAD(90.0);  p2.rho = EARTH_RADIUS; p2.theta = -1.0 * DEGTORAD(lon2); p2.phi = (DEGTORAD(-1.0 * lat2)) + DEGTORAD(90.0);  /***************************************************************************** *                                                                            * *  Compute the distance between the points.                                  * *                                                                            * *****************************************************************************/  arclen(p1, p2, d);  return 0;  }  C:\《算法精解C语言实现》例子代码\examples_pc\source\arclen.c /***************************************************************************** *                                                                            * *  ------------------------------- arclen.c -------------------------------  * *                                                                            * *****************************************************************************/  #include <math.h>  #include "geometry.h"  /***************************************************************************** *                                                                            * *  -------------------------------- arclen --------------------------------  * *                                                                            * *****************************************************************************/  void arclen(SPoint p1, SPoint p2, double *length) {  Point              p1_rct,                    p2_rct;  double             alpha,                    dot;  /***************************************************************************** *                                                                            * *  Convert the spherical coordinates to rectilinear coordinates.             * *                                                                            * *****************************************************************************/  p1_rct.x = p1.rho * sin(p1.phi) * cos(p1.theta); p1_rct.y = p1.rho * sin(p1.phi) * sin(p1.theta); p1_rct.z = p1.rho * cos(p1.phi);  p2_rct.x = p2.rho * sin(p2.phi) * cos(p2.theta); p2_rct.y = p2.rho * sin(p2.phi) * sin(p2.theta); p2_rct.z = p2.rho * cos(p2.phi);  /***************************************************************************** *                                                                            * *  Get the angle between the line segments from the origin to each point.    * *                                                                            * *****************************************************************************/  dot = (p1_rct.x * p2_rct.x) + (p1_rct.y * p2_rct.y) + (p1_rct.z * p2_rct.z); alpha = acos(dot / pow(p1.rho, 2.0));  /***************************************************************************** *                                                                            * *  Compute the length of the arc along the spherical surface.                * *                                                                            * *****************************************************************************/  *length = alpha * p1.rho;  return;  }  C:\《算法精解C语言实现》例子代码\examples_pc\include\geometry.h /***************************************************************************** *                                                                            * *  ------------------------------ geometry.h ------------------------------  * *                                                                            * *****************************************************************************/  #ifndef GEOMETRY_H #define GEOMETRY_H  #include "list.h"  /***************************************************************************** *                                                                            * *  Define an approximation for Pi.                                           * *                                                                            * *****************************************************************************/  #ifndef PI #define            PI                    3.14159 #endif  /***************************************************************************** *                                                                            * *  Define macros for comparisons.                                            * *                                                                            * *****************************************************************************/  #define            MIN(x, y)             (((x) < (y)) ? (x) : (y)) #define            MAX(x, y)             (((x) > (y)) ? (x) : (y))  /***************************************************************************** *                                                                            * *  Define macros for converting between degrees and radians.                 * *                                                                            * *****************************************************************************/  #define            DEGTORAD(deg)         (((deg) * 2.0 * PI) / 360.0) #define            RADTODEG(rad)         (((rad) * 360.0) / (2.0 * PI))  /***************************************************************************** *                                                                            * *  Define a structure for points in rectilinear coordinates.                 * *                                                                            * *****************************************************************************/  typedef struct Point_ {  double             x,                    y,                    z;  } Point;  /***************************************************************************** *                                                                            * *  Define a structure for points in spherical coordinates.                   * *                                                                            * *****************************************************************************/  typedef struct SPoint_ {  double             rho,                    theta,                    phi;  } SPoint;  /***************************************************************************** *                                                                            * *  --------------------------- Public Interface ---------------------------  * *                                                                            * *****************************************************************************/  int lint(Point p1, Point p2, Point p3, Point p4);  int cvxhull(const List *P, List *polygon);  void arclen(SPoint p1, SPoint p2, double *length);  #endif

user: user-0
content: 恳请大神指点一二，小弟感激不尽！！！

user: user-0
content: {"Newcastle-on-Tyne,England",54.97,-1.62},           {"Nome,AK,USA",64.42,-165.5},           {"Oakland,CA,USA",37.8,-122.27},           {"Odessa,Ukraine",46.45,30.8},           {"Oklahoma City,OK,USA",35.43,-97.47},           {"Omaha,NE,USA",41.25,-95.93},           {"Osaka,Japan",34.53,135.5},           {"Oslo,Norway",59.95,10.7},           {"Ottawa,ON,Canada",45.4,-75.72},           {"Panama City,Panama",8.97,-79.53},           {"Paramaribo,Suriname",5.75,-55.25},           {"Paris,France",48.8,2.33},           {"Perth,Australia",-31.95,115.87},           {"Philadelphia,PA,USA",39.95,-75.17},           {"Phoenix,AZ,USA",33.48,-112.07},           {"Pierre,SD,USA",44.37,-100.35},           {"Pittsburgh,PA,USA",40.45,-79.95},           {"Plymouth,England",50.42,-4.08},           {"Port Moresby,Papua New Guinea",-9.42,147.13},           {"Portland,ME,USA",43.67,-70.25},           {"Portland,OR,USA",45.52,-122.68},           {"Prague,Czech Republic",50.08,14.43},           {"Providence,RI,USA",41.83,-71.4},           {"Quebec,QC,Canada",46.82,-71.18},           {"Raleigh,NC,USA",35.77,-78.65},           {"Rangoon,Myanmar",16.83,96.0},           {"Reno,NV,USA",39.5,-119.82},           {"Reykjavik,Iceland",64.07,-21.97},           {"Richfield,UT,USA",38.77,-112.08},           {"Richmond,VA,USA",37.55,-77.48},           {"Rio de Janeiro,Brazil",-22.95,-43.2},           {"Roanoke,VA,USA",37.28,-79.95},           {"Rome,Italy",41.9,12.45},           {"Sacramento,CA,USA",38.58,-121.5},           {"Salt Lake City,UT,USA",40.77,-111.9},           {"Salvador,Brazil",-12.93,-38.45},           {"San Antonio,TX,USA",29.38,-98.55},           {"San Diego,CA,USA",32.7,-117.17},           {"San Francisco,CA,USA",37.78,-122.43},           {"San Jose,CA,USA",37.33,-121.88},           {"San Juan,PR,USA",18.5,-66.17},           {"Santa Fe,NM,USA",35.68,-105.95},           {"Santiago,Chile",-33.47,-70.75},           {"Savannah,GA,USA",32.08,-81.08},           {"Seattle,WA,USA",47.62,-122.33},           {"Shanghai,China",31.17,121.47},           {"Shreveport,LA,USA",32.47,-93.7},           {"Singapore,Singapore",1.23,103.92},           {"Sioux Falls,SD,USA",43.55,-96.73},           {"Sitka,AK,USA",57.17,-135.25},           {"Sofia,Bulgaria",42.67,23.33},           {"Spokane,WA,USA",47.67,-117.43},           {"Springfield,IL,USA",39.8,-89.63},           {"Springfield,MA,USA",42.1,-72.57},           {"Springfield,MO,USA",37.22,-93.28},           {"St John's,NL,Canada",45.3,-66.17},           {"St Louis,MO,USA",38.58,-90.2},           {"St. Petersburg,Russia",59.93,30.3},           {"Stockholm,Sweden",59.28,18.05},           {"Sydney,Australia",-34.0,151.0},           {"Syracuse,NY,USA",43.03,-76.13},           {"Sao Paulo,Brazil",-23.52,-46.52},           {"Tampa,FL,USA",27.95,-82.45},           {"Tananarive,Madagascar",-18.83,47.55},           {"Teheran,Iran",35.75,51.75},           {"Tokyo,Japan",35.67,139.75},           {"Toledo,OH,USA",41.65,-83.55},           {"Toronto,ON,Canada",43.67,-79.4},           {"Tripoli,Libya",32.95,13.2},           {"Tulsa,OK,USA",36.15,-95.98},           {"Vancouver,BC,Canada",49.22,-123.1},           {"Venice,Italy",45.43,12.33},           {"Veracruz,Mexico",19.17,-96.17},           {"Victoria,BC,Canada",48.42,-123.35},           {"Vienna,Austria",48.23,16.33},           {"Virginia Beach,VA,USA",36.85,-75.97},           {"Vladivostok,Russia",43.17,132.0},           {"Warsaw,Poland",52.23,21.0},           {"Washington,DC,USA",38.88,-77.03},           {"Wellington,New Zealand",-41.28,174.78},           {"Wichita,KS,USA",37.72,-97.28},           {"Wilmington,NC,USA",34.23,-77.95},           {"Winnipeg,MB,Canada",49.9,-97.12},           {"Zurich,Switzerland",47.35,8.52},           {"",999,999}};

user: user-0
content: 数据库如下：  #define MAX_CITY_LEN   35  typedef struct {                  char  name[MAX_CITY_LEN];                 float latitude;                 float longitude;                } PLACE_T;  PLACE_T places[] =          {{"Aberdeen,Scotland",57.15,-2.15},           {"Adelaide,Australia",-34.92,138.6},           {"Albany,NY,USA",42.67,-73.75},           {"Albuquerque,NM,USA",35.08,-106.65},           {"Algiers,Algeria",36.83,3.0},           {"Amarillo,TX,USA",35.18,-101.83},           {"Amsterdam,Netherlands",52.37,4.88},           {"Anchorage,AK,USA",61.22,-149.9},           {"Ankara,Turkey",39.92,32.92},           {"Asuncion,Paraguay",-25.25,-57.67},           {"Athens,Greece",37.97,23.72},           {"Atlanta,GA,USA",33.75,-84.38},           {"Auckland,New Zealand",-36.87,174.75},           {"Austin,TX,USA",30.27,-97.73},           {"Baker,OR,USA",44.78,-117.83},           {"Baltimore,MD,USA",39.3,-76.63},           {"Bangkok,Thailand",13.75,100.5},           {"Bangor,ME,USA",44.8,-68.78},           {"Barcelona,Spain",41.38,2.15},           {"Beijing,China",39.92,116.42},           {"Belfast,Northern Ireland",54.62,-5.93},           {"Belgrade,Serbia",44.87,20.53},           {"Belem,Brazil",-1.47,-48.48},           {"Berlin,Germany",52.5,13.42},           {"Birmingham,AL,USA",33.5,-86.83},           {"Birmingham,England",52.42,-1.92},           {"Bismarck,ND,USA",46.8,-100.78},           {"Bogota,Colombia",4.53,-74.25},           {"Boise,ID,USA",43.6,-116.22},           {"Bombay,India",19.0,72.8},           {"Bordeaux,France",44.83,-0.52},           {"Boston,MA,USA",42.35,-71.08},           {"Bremen,Germany",53.08,8.82},           {"Brisbane,Australia",-27.48,153.13},           {"Bristol,England",51.47,-2.58},           {"Brussels,Belgium",50.87,4.37},           {"Bucharest,Romania",44.42,26.12},           {"Budapest,Hungary",47.5,19.08},           {"Buenos Aires,Argentina",-34.58,-58.37},           {"Buffalo,NY,USA",42.92,-78.83},           {"Cairo,Egypt",30.03,31.35},           {"Calcutta,India",22.57,88.4},           {"Calgary,AB,Canada",51.02,-114.02},           {"Canton,China",23.12,113.25},           {"Cape Town,South Africa",-33.92,18.37},           {"Caracas,Venezuela",10.47,-67.03},           {"Carlsbad,NM,USA",32.43,-104.25},           {"Cayenne,French Guiana",4.82,-52.3},           {"Charleston,SC,USA",32.78,-79.93},           {"Charleston,WV,USA",38.35,-81.63},           {"Charlotte,NC,USA",35.23,-80.83},           {"Cheyenne,WY,USA",41.15,-104.87},           {"Chicago,IL,USA",41.83,-87.62},           {"Chihuahua,Mexico",28.62,-106.08},           {"Chongqing,China",29.77,106.57},           {"Cincinnati,OH,USA",39.13,-84.5},           {"Cleveland,OH,USA",41.47,-81.62},           {"Columbia,SC,USA",34.0,-81.03},           {"Columbus,OH,USA",40.0,-83.02},           {"Copenhagen,Denmark",55.67,12.57},           {"Cordoba,Argentina",-31.47,-64.17},           {"Dakar,Senegal",14.67,-17.47},           {"Dallas,TX,USA",32.77,-96.77},           {"Darwin,Australia",-12.47,130.85},           {"Denver,CO,USA",39.75,-105.0},           {"Des Moines,IA,USA",41.58,-93.62},           {"Detroit,MI,USA",42.33,-83.05},           {"Djibouti,Djibouti",11.5,43.05},           {"Dublin,Ireland",53.33,-6.25},           {"Dubuque,IA,USA",42.52,-90.67},           {"Duluth,MN,USA",46.82,-92.08},           {"Durban,South Africa",-29.88,30.88},           {"Eastport,ME,USA",44.9,-67.0},           {"Edinburgh,Scotland",55.92,-3.17},           {"Edmonton,AB,Canada",53.57,-113.47},           {"El Centro,CA,USA",32.63,-115.55},           {"El Paso,TX,USA",31.77,-106.48},           {"Eugene,OR,USA",44.05,-123.08},           {"Fargo,ND,USA",46.87,-96.8},           {"Flagstaff,AZ,USA",35.22,-111.68},           {"Fort Worth,TX,USA",32.72,-97.32},           {"Frankfurt,Germany",50.12,8.68},           {"Fresno,CA,USA",36.73,-119.8},           {"Georgetown,Guyana",6.75,-58.25},           {"Glasgow,Scotland",55.83,-4.25},           {"Grand Junction,CO,USA",39.08,-108.55},           {"Grand Rapids,MI,USA",42.97,-85.67},           {"Guatemala City,Guatemala",14.62,-90.52},           {"Guayaquil,Ecuador",-2.17,-79.93},           {"Hamburg,Germany",53.55,10.03},           {"Hammerfest,Norway",70.63,23.63},           {"Havana,Cuba",23.13,-82.38},           {"Havre,MT,USA",48.55,-109.72},           {"Helena,MT,USA",46.58,-112.03},           {"Helsinki,Finland",60.17,25.0},           {"Hobart,Tasmania",-42.87,147.32},           {"Hong Kong,China",22.33,114.18},           {"Honolulu,HI,USA",21.3,-157.83},           {"Hot Springs,AR,USA",34.52,-93.05},           {"Houston,TX,USA",29.75,-95.35},           {"Idaho Falls,ID,USA",43.5,-112.02},           {"Indianapolis,IN,USA",39.77,-86.17},           {"Iquique,Chile",-20.17,-70.12},           {"Irkutsk,Russia",52.5,104.33},           {"Jackson,MS,USA",32.33,-90.2},           {"Jacksonville,FL,USA",30.37,-81.67},           {"Jakarta,Indonesia",-6.27,106.8},           {"Johannesburg,South Africa",-26.2,28.07},           {"Juneau,AK,USA",58.3,-134.4},           {"Kansas City,MO,USA",39.1,-94.58},           {"Key West,FL,USA",24.55,-81.8},           {"Kingston,Jamaica",17.98,-76.82},           {"Kingston,ON,Canada",44.25,-76.5},           {"Kinshasa,Congo",-4.3,15.28},           {"Klamath Falls,OR,USA",42.17,-121.73},           {"Knoxville,TN,USA",35.95,-83.93},           {"Kuala Lumpur,Malaysia",3.13,101.7},           {"La Paz,Bolivia",-16.45,-68.37},           {"Las Vegas,NV,USA",36.17,-115.2},           {"Leeds,England",53.75,-1.5},           {"Lewiston,ID,USA",46.4,-117.03},           {"Lima,Peru",-12.0,-77.03},           {"Lincoln,NE,USA",40.83,-96.67},           {"Lisbon,Portugal",38.73,-9.15},           {"Liverpool,England",53.42,-3.0},           {"London,England",51.53,-0.08},           {"London,ON,Canada",43.03,-81.57},           {"Long Beach,CA,USA",33.77,-118.18},           {"Los Angeles,CA,USA",34.05,-118.25},           {"Louisville,KY,USA",38.25,-85.77},           {"Lyons,France",45.75,4.83},           {"Madrid,Spain",40.43,-3.7},           {"Manchester,England",53.5,-2.25},           {"Manchester,NH,USA",43.0,-71.5},           {"Manila,Philippines",14.58,120.95},           {"Marseilles,France",43.33,5.33},           {"Mazatlan,Mexico",23.2,-106.42},           {"Mecca,Saudi Arabia",21.48,39.75},           {"Melbourne,Australia",-37.78,144.97},           {"Memphis,TN,USA",35.15,-90.05},           {"Mexico City,Mexico",19.43,-99.12},           {"Miami,FL,USA",25.77,-80.2},           {"Milan,Italy",45.45,9.17},           {"Milwaukee,WI,USA",43.03,-87.92},           {"Minneapolis,MN,USA",44.98,-93.23},           {"Mobile,AL,USA",30.7,-88.05},           {"Montevideo,Uruguay",-34.88,-56.17},           {"Montgomery,AL,USA",32.35,-86.3},           {"Montpelier,VT,USA",44.25,-72.53},           {"Montreal,QC,Canada",45.5,-73.58},           {"Moose Jaw,SK,Canada",50.62,-105.52},           {"Moscow,Russia",55.75,37.6},           {"Munich,Germany",48.13,11.58},           {"Nagasaki,Japan",32.8,129.95},           {"Nagoya,Japan",35.12,136.93},           {"Nairobi,Kenya",-1.42,36.92},           {"Nanjing,China",32.05,118.88},           {"Naples,Italy",40.83,14.25},           {"Nashville,TN,USA",36.17,-86.78},           {"Nelson,BC,Canada",49.5,-117.28},           {"New Delhi,India",28.58,77.2},           {"New Haven,CT,USA",41.32,-72.92},           {"New Orleans,LA,USA",29.95,-90.07},           {"New York,NY,USA",40.78,-73.97},           {"Newark,NJ,USA",40.73,-74.17},