#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string>using namespace STD;typedef intElemtype;intSize=0;typedef structnode{Charname[ -];floatx, y; Elemtype data; Node *next;} Node,*linklist;voidBuild (linklist L) {linklist p,q;intN P=l;printf("Please enter the number of cities to build \ n");scanf("%d", &n); while(n--) {q= (linklist)malloc(sizeof(Node));printf("Please enter the name of the city \ n");scanf('%s ', &q->name);printf("Please enter the coordinates of the city x\n");scanf("%f", &q->x);printf("Please enter the coordinates of the city y\n");scanf("%f", &q->y); q->next=null; p->next=q; p=q; size++; }}voidPrint (linklist L)//Calculate the length of a single linked list, then output a single linked list{intnum=0; Linklist p; p=l->next; while(p) {num++;printf("The name of the city is: \ n");printf('%s ', p->name);printf("The coordinates of the city are%f%f\n", p->x,p->y); p=p->next; }printf("\ n length is%d:\n", num);}voidLookcoordinate (linklist L) {linklist p,q;//p=l; Chara[ -];printf("Please enter the name of the city you are looking for \ n");scanf('%s ', &a); for(p = l->next; p! = NULL; p = p->next)if(!strcmp(P->name,a))The//c/c++ function compares two strings. Set these two strings to STR1,STR2, and if STR1==STR2, return 0{printf("Please find the coordinates of the city is%f%f\n", p->x,p->y); Break; }}voidList (linklist L) {Chara[ -]; Node *p; Node N;intIfloatDfloatDe;cout<<"You give the city is:";Cin>>a;cout<<"The distance you Give is:";Cin>>d; for(p = l->next; p! = NULL; p = p->next)if(!strcmp(P->name,a)) Break; n = *p; p = l->next; for(i=0; i<size;i++, p = p->next) {de=sqrt(((*p). x-n.x) * ((*p). x-n.x) + ((*p). Y-n.y) * ((*p). y-n.y));if(De<=d &&strcmp(P->name,a)) {cout<<p->name;cout<<' ('<<p->x<<', '<<p->y<<' ) '<<endl; } }}intMain () {linklist L;intN L= (linklist)malloc(sizeof(Node)); l->next=null; Build (L);printf("You can return the coordinates by selecting-----1 to find the city name-----\ n");printf("You can find the city perimeter by selecting-----2-----\ n");scanf("%d", &n); while(n) {Switch(n) { Case 1: Lookcoordinate (L); Break; Case 2: List (L); Break; }scanf("%d", &n); }//Print (L);}
List of characters (ii)