Home > Back-end >  Bosses how to solve this problem?
Bosses how to solve this problem?

Time:09-24

1> D: \ basic experiment, experiment 2: computer software stack and queue, car park management simulation, car park management simulation. CPP (, 182) : error C3688: textual suffix, "c1" is invalid. Computation of the operator was not found or text operator template "operator", ""," c1 "//parking management simulation. CPP: this file contains the" main "function, the program execution will start and end here, 4 # define N//maximum capacity to define the garage

# include & lt; Stdio. H>
# include & lt; Stdlib. H>
# include & lt; The malloc. H>
# include & lt; Time. H>
# include & lt; String. H>
# include & lt; Math. H>

Typedef struct {//define the parking registration structure
Time_t arrtime;
Time_t leatime;
Int ID;
} the Car;

Typedef struct {//define the garage stack
The Car stack [N].
Int top;
} seqparklist;

Typedef struct LoadNode {//defined in the queue queue
The Car loadnode;
LoadNode * next;
} LoadNode, * LoadList; Seqparklist Park, Park2;//Park to the parking lot, Park2 for transit
LoadList Load;////sidewalks initialization

//initialize the service road
Void InitQueue (LoadList * Q) {
Q=(LoadList *) malloc (sizeof (LoadNode));
(* Q) - & gt; Next=NULL;

}

//initialize the parking
Void InitSeqStack seqparklist * (top)
{
Top - & gt; Top=1;
}

//car into the sidewalk
Int EnterQueue (Car * Car) {
Int order=0;
P1 LoadNode * * (p2);
P1=p2=Load;
LoadNode * newCar=(LoadNode *) malloc (sizeof (LoadNode));//find a party, return position
While (p1!=NULL) {order++; P1 p2=; P1=p1 - & gt; next;
}
NewCar - & gt; Loadnode=* car;
The p2 - & gt; Next=newCar;
NewCar - & gt; Next=NULL;
Return the order;
}

//whether the parking lot is full
Bool isFull () {
If (Park. The top==N - 1) return true;
return false;
}

//whether the parking lot is empty
Bool isParkEmpty (seqparklist * park) {
If (park - & gt; Top==1) return true;
return false;
}//car service road
Int DeleteQueue (Car * Car) {
LoadNode * ycar.
Ycar=Load - & gt; next;
If (ycar==NULL) return 0;
* car=ycar - & gt; Loadnode;
The Load - & gt; Next=ycar - & gt; next;
Free (ycar);
return 1;
}//car into the parking lot
Int a Push (seqparklist * S, Car * Car) {
If (S - & gt; Top==N - 1) return 1;
S - & gt; Top++;
Time (& amp; The car - & gt; Arrtime);
S - & gt; Stack [S - & gt; top]=* car;
The return of S - & gt; Top;
}//parking the car outside
Int GetTop (seqparklist * S, Car * Car) {
If (S - & gt; Top==1) return S - & gt; Top;
* the car=S - & gt; Stack [S - & gt; top];
The return of S - & gt; Top;
}//compare two car
Bool ComCar (c2) of Car c1, Car {
If (c1) ID==c2) ID) return true;
return false;
}//into the parking lot to outbound car provide local
Int MoveIn (seqparklist * S, Car * Car) {
If (S - & gt; Top==N - 1) return 1;
S - & gt; Top++;
S - & gt; Stack [S - & gt; top]=* car;
The return of S - & gt; Top;
}

Int MoveOut (seqparklist * S, Car * Car) {
If (S - & gt; Top==1) return S - & gt; Top;
* the car=S - & gt; Stack [S - & gt; top];
S - & gt; Top -;
The return of S - & gt; Top + 1;
}

//car parking
Int Pop (seqparklist * S, Car * Car) {
If (S - & gt; Top==1) return S - & gt; Top;
* the car=S - & gt; Stack [S - & gt; top];
Time (& amp; The car - & gt; Leatime);
S - & gt; Top -;
The return of S - & gt; Top + 1;
}//cars enter
Void Carin (Car * Car) {
Int the order;
The order=EnterQueue (car);
If (isFull ())//whether the parking lot is full
{printf (" % d car has entered the service road position waiting for! \ n ", the order);
}

The else {
The Car xcar;
DeleteQueue (& amp; Xcar);//the service road
The order=Push (& amp; Park, & amp; Xcar);//into the parking lot
Printf (" the car has entered the parking position % d \ n ", the order + 1);
}
}

//a car to leave
Void Carout (Car * Car) {
If (isParkEmpty (& amp; Park)) {printf (" parking lot is empty!" );
}
The else {Car c1; GetTop (& amp; Park, & amp; C1);//if the parking lot outside the car is not going to leave, then removed from the stack, stack into another, until the most outside the garage for outbound car while (! ComCar (c1, * car)) {MoveOut (& amp; Park, & amp; C1); MoveIn (& amp; Park2, & amp; C1); GetTop (& amp; Park, & amp; C1); } int order=Pop (& amp; Park, & amp; C1); Printf (" this car in the parking lot for % typical vmlinux.lds and cost % d yuan (RMB 60 s/2) \ n ", (c1) leatime - c1) arrtime), (c1) leatime - c1) arrtime + 9)/60 * 2); while (! IsParkEmpty (& amp; Park2)) {MoveOut (& amp; Park2, & amp; C1); MoveIn (& amp; Park, & amp; C1); }
}
The Car c1;
If (DeleteQueue (& amp; C1)) {Push (& amp; Park, & amp; C1);
}
} int main ()
{
InitQueue (& amp; The Load);
InitSeqStack (& amp; Park);
InitSeqStack (& amp; Park2);
Seqparklist park, park2;
LoadList Load;
The Car car1.
Printf ("/n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- welcome to use the parking lot management system -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -/n ");
Printf (" please enter the license plate number, enter the Aor leave are quit E: \ n ");
Char action;
Scanf_s (" % d % c ", & amp; Car1. ID & amp; The action, sizeof (action));
The switch (action)
{
Case 'a' :
Case 'A' : Carin (& amp; Car1); break;
Case 'd' :
Case 'D' : Carout (& amp; Car1); break;
Case 'e' :
Case 'E' : printf (" \ n \ n normal program ended "); break;
default: break;
} printf (" please enter the license plate number, enter the Aor leave are quit E: \ n "); Scanf_s (" % d % c ", & amp; Car1. ID & amp; The action, sizeof (action)); }

CodePudding user response:

Because should input the Chinese comma so go wrong
  • Related