A single list of problems ~ compilation but can not realize the function help ~

Topic: some city information input in a single linked list node, node of city information including the name of the city, city position coordinate, requirements: (1) given a city name, return position; (2) for a given location coordinates P and a distance D, return all distance is less than or equal to D and P City.
Write code for the:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
typedef struct city //With the structure to define a single list
{
char name; //The city name (string type, not string, C language string array implementation dependent)
int hengzuobiao; //City abscissa
int zongzuobiao; //City ordinate
struct city *next; //Point to your pointer next
}city,*LinkList; //The struct city class city, LinkList structure pointer types
void InitList(LinkList *H) //Initialization list
{
*H=(LinkList)malloc(sizeof(city));//A head node
(*H)->next=NULL; //The establishment of air single chain H
}
void CreatFromTail(LinkList H)//Tail interpolation tables
{
city *r,*s;
char n;
int x,y;
int flag=1; //Sets a flag, the initial value is 1, when the input "$", flag=0, the end of the table
r=H; //The R pointer pointing to list the current dynamic end, to facilitate the tail insertion, the initial point to the head node
while(flag) //Circulation in the input table element values, will create a new node s is inserted into the tail
{
printf("Enter the city name (to terminate in the information, please input$):\n");
scanf("%s",&n);//String
getchar(); //Do not start with getchar () function, scanf ("%s", & n) will be skipped, "input output (city name to terminate in the information, please input $):" after the direct output "input city coordinate:". Why!!!!
if(n!='$')
{
printf("City coordinates input: \n");
scanf("%d%d",&x,&y); //The horizontal and vertical coordinates input City
s=(city *)malloc(sizeof(city)); //To apply for a new node
s->name=n;
s->hengzuobiao=x;
s->zongzuobiao=y;
r->next=s;
r=s; //R always point to a single table tail
}
else
{
flag=0;
r->next=NULL; //The next chain domain the last node set is empty, said the end of the list
}
}
}
void search() //Query city coordinate
{
LinkList L;//The lead single node chain L find the node value is equal to the key node, if find the city coordinates is returned; otherwise it returns NULL
CreatFromTail(L);
char key;
city *p;
printf("Please input the name of the city: ");
scanf("%d",&key);
p=L->next; //From the table, the first comparison of nodes
while(p!=NULL)
if(p->name!=key)
p=p->next; //P points to the next node
else
{
printf("The city coordinates: ",p->hengzuobiao,p->zongzuobiao);
break; //Find node key, exit the loop
}
}
void calculate() //Calculate the distance
{
LinkList L;
CreatFromTail(L);
int m,n,D;
city *p;
printf("Please input the coordinates of P: ");
scanf("%d%d",&m,&n);
printf("Please enter a distance D: ");
scanf("%d",&D);
p=L->next; //From the table, the first comparison of nodes
while(p!=NULL)
if((m-p->hengzuobiao)*(m-p->hengzuobiao)+(n-p->zongzuobiao)*(n-p->zongzuobiao)<=(D*D))
{
printf("The city to meet the conditions:",p->name);
}
else
p=p->next; //To compare the next node
}
void main()
{
int number;
printf("Please select a number: 1 query city coordinate 2 output is consistent with the distance conditions of the city 3 exit system \n");
scanf("%d",&number);
switch(number)
{
case 1:
search();
break;
case 2:
calculate();
break;
case 3:
printf("Has been successfully quit! Welcome to use!");
break;
default:
printf("Input error, please input again");
break;
}
system("pause");
}
Have a look how should modify the program.~~~~~~~

Started by Becky at November 17, 2016 - 2:01 AM

In the final analysis code function not others to help yourself or to explain or comment out; but by their static next hearts come spend enough time and energy in hands-on step or set a breakpoint or on the execution to the display or written to the log file in a step-by-step analysis out of a step to obtain intermediate results.
Remind: then cattle X teacher cannot replace the student own understanding and the toilet´╝ü
Single step debugging and set a breakpoint debugging is one of the programmer must master skills.

Posted by Elijah at November 27, 2016 - 2:35 AM