求解三条C语言的题目(EN)

来源:百度知道 编辑:UC知道 时间:2024/05/19 21:22:17
EdgeLane Airlines has a fleet of one plane with a seating capacity of 14 arranged as 7 rows (1 to 7) of two seats (A and B) (i.e. the seat identification labels are 1A, 1B, …). It makes one flight a day. Write a seating reservation program with the following features:
1. The program uses an array of 14 structures. Each structure should hold a seat identification label, a flag that indicates whether the seat is assigned, the last name of the seat holder (max 20 characters), and the first name of the seat holder (max 20 characters).
2. The program displays the following menu:
To choose a function, enter its letter label:
a) Show assigned seats with passenger names.
b) Show list of empty seats.
c) Assign a customer to a seat.
d) Edit customer details, for a specific seat.
e) Delete a seat assignment.
f) Quit.
After executing a particular function the program should show the menu again except for choice (f)
3. The program sh

#include <iostream>
#include <stdio.h>
#define M 2
#define N 7
using namespace std;

struct pass
{
int as;
char fname[20];
char lname[20];
}seat[M][N];

void init()
{
for(int i=0;i<2;i++)
{

for(int j=0;j<7;j++)
{
seat[i][j].as=0;
strcpy(seat[i][j].fname,"empty");
strcpy(seat[i][j].lname,"empty");
}

}
}

void read()
{
FILE *fp;
int i=0,j=0;
if((fp=fopen("c:\\seat.txt","rb"))==NULL)
{
cout<<"No information inputed,system has initialed it."<<endl;
init();
}

for(i=0;i<2;i++)
{
for(j=0;j<7;j++)
{
fread(&seat[i][j],sizeof(struct pass),1,fp);
cout<<"seat "<<i<<" "<<j<<"loaded&qu