Traditional Culture Encyclopedia - Tourist attractions - C language homework. Tourist attractions management program (freshman assignment) is mainly realized by structure array, and each record is represented by structure, including data.
C language homework. Tourist attractions management program (freshman assignment) is mainly realized by structure array, and each record is represented by structure, including data.
# include & ltstdlib.h & gt
# include & ltstring.h & gt
/*-Data area */
int SIZE = 2;
Structure point {
char id[ 10]; //scenic spot number
char name[20]; //Name of scenic spot
Char address [50]; //address of scenic spots
Floating cost; //Cost
};
Construct scenic spots [20];
char sub _ id[ 10]; //Used to store the number of scenic spots to query, modify or delete.
/*-Function declaration area.
Void input (spot scene, int size); //Input function
Void Del(Spot landscape [], char sub_id[], int& size); //Delete function
void Alter(Spot scene[],char sub_id[],int SIZE); //Modify the function
Void output (spot scene, int size); //Display function
void Select(Spot scene[],char sub_id[],int SIZE); //Query function
void Count(Spot scene[],int SIZE); //Statistical function
void Exit(); //Exit function
/*-Function definition area.
Void input (scenic spot scenery [10], int SIZE)
{
int I;
Printf ("Please enter \ n");
printf("-\ n ");
for(I = 0; I< size; i++)
{
Printf ("Please enter ID:");
Get (scenery [i]. id);
Printf ("Please enter your name:");
Get (scenery [i]. Name);
Printf ("Please enter the address:");
Get (scenery [i]. Address);
Printf ("Please enter the fee:");
Scanf("%f ",& Landscape [me]. Cost);
fflush(stdin); //Clear the keyboard buffer
printf(" \ n ");
}
printf("-\ n ");
}
Void Del(Spot landscape [], char sub_id[], int& size)
{
int i,j;
Printf ("Please enter the ID of the deletion point:");
Get (sub _ id);
for(I = 0; I< size; i++)
{
If(strcmp (scenery [i]). id,sub_id)==0)
{
for(j = I; J< size; j++)
Landscape [j]= landscape [j+1];
Size-;
}
}
printf("-\ n ");
}
Void Alter (scenic spot [], char sub_id[], int SIZE)
{
int I;
Printf ("Please enter the ID of the change point:");
Get (sub _ id);
for(I = 0; I< size; i++)
{
If(strcmp (scenery [i]). id,sub_id)==0)
{
Printf("alter spot's name is: ");
Get (scenery [i]. Name);
Printf("alter spot's address is: ");
Get (scenery [i]. Address);
Printf ("the cost of alterspot is:");
Scanf("%f ",& Landscape [me]. Cost);
fflush(stdin);
Break;
}
}
printf("-\ n ");
}
Void output (spot scene, int SIZE)
{
int I;
Printf ("output scenery: \ n");
printf("-\ n ");
for(I = 0; I< size; i++)
{
Printf("id:%s Name: %s Address: %s Overhead: %.2f\n ",scenery. Id, scenery [me] Name, scenery [me]. Address, scenery [me]. Cost);
}
printf("-\ n ");
}
Void Select (scenic spot [], char sub_id[], int SIZE)
{
int I;
Printf ("Please enter the ID of the selection point:");
Get (sub _ id);
Printf ("-query result ");
for(I = 0; I< size; i++)
{
If(strcmp (scenery [i]). id,sub_id)==0)
Printf("id:%s Name: %s Address: %s Overhead: %.2f\n ",scenery. Id, scenery [me] Name, scenery [me]. Address, scenery [me]. Cost);
}
}
Empty count (scenic spot scenery [], int size)
{
int I;
Floating sum; //sum is used to store the total cost.
Printf ("-statistical results ");
for(i=0,sum = 0; I< size; i++)
Sum+= scenery [i]. Cost;
Printf ("Scene number: %d cost: %.2f\n", size, sum);
}
Void exit ()
{
printf("-\ n ");
Exit (1);
}
/*-Main function *
void main()
{
int s;
while( 1)
{
Printf ("Please enter: \ n");
Printf(" 1, enter. \n2。 Delete. \n3。 Modify. \n4。 Show. \n5。 Asking. \n6。 Statistics. \n7。 Quit \ n ");
scanf("%d ",& amps);
fflush(stdin);
switch
{
Case 1: input (scene, size); Break;
Case 2: Del (landscape, sub_id, size); Break;
Case 3: Alter (scene, sub_id, size); Break;
Case 4: output (scenery, size); Break;
Case 5:Select (scene, sub_id, size); Break;
Case 6: Counting (scenery, size); Break;
Case 7: exit (); Break;
Default: printf ("Please enter again:"); Break;
}
}
}
- Previous article:What are the routes worth visiting from go on road trip to Hainan?
- Next article:Moving brand copywriting of agricultural products
- Related articles
- What are the specialties of Correspondence Law?
- What are the penalties for complaining about tour guides?
- I am traveling to Yunnan by car with my wife, what insurance do we need to buy?
- How much does the China-Europe special train cost?
- Guide to Chengdu Giant Panda Research Base.
- What is the main job of the accompanying photographer?
- Teach you how to calculate the travel quotation.
- Article about St. Petersburg: A city carved in a painting
St Petersburg is the second largest city in Russia and plays an important role in the domestic economy. At the same time, it is also the
- What tourist attractions will you pass along the Beijing-Hong Kong-Macao Expressway from Shijiazhuang to Guilin?
- When is the best time to travel to Nepal?