Home > Back-end >  Please help to look at, the program went wrong?
Please help to look at, the program went wrong?

Time:01-05

This program reservation management system is the design of the background, features order, query, modify, delete, view existing reservation list, exit systems, translation no errors, but running in the query, modify, and delete the error in the three functions, select the Numbers for 1 for function operation no problem, but the number is 1 will come out a design first after an error "no query to modify/delete data", but the selection function can continue to run, can modify delete as usual, for example, every back to the first error, just don't know what the problem with the program, please help to look at it?



Procedure is as follows:
#include
#include
# define MaxSize 20
Struct guest_info {
char name[10];
Int sum;
Char time [10].
int num;
} guest [MaxSize];
Void Insert (int * count);
Void Search (int count);
Void the Update (int count);
Void the Delete (int * count);
Void Show (int count);
Void Exit (void);
Int main ()
{
int i;
int count=0;
Do
{printf (" \ n ");
Printf (" 1 -- order (Insert) \ n ");
Printf (" 2 -- query (Search) \ n ");
Printf (" 3 -- change order information (Update) \ n ");
Printf (" 4 - Delete orders (Delete) \ n ");
Printf (" 5 - shows reservation information (Show) \ n ");
Printf (" 6 - Exit (Exit) \ n ");
The scanf (" % d ", & amp; I);
The switch (I)
{case 1: Insert (& amp; The count);
break;
Case 2: Search (count);
break;
Case 3: the Update (count);
break;
Case 4: Delete (& amp; The count);
break;
Case 5: Show (count);
break;
Case 6: the Exit ();
break;
Default: printf (" wrong choice! Please re-election ");
}
} while (I!=8);
return 0;
}

Void Insert (int * count)
{int I in_num;
If the count (*==MaxSize)
{printf (" the space is full!" ); return ; }
Printf (" please enter a number: ");
The scanf (" % d ", & amp; In_num);
for(i=0; i<* count; I++)
If (guest [I] num==in_num)
{printf (" has the same number, please operate again, \ n "); return ; }
Guest [I] num=in_num;
Printf (" please input your name: ");
The scanf (" % s ", guest [I] name);
Printf (" please enter a number: ");
The scanf (" % d ", & amp; Guest [I] sum);
Printf (" please enter the meal time: ");
The scanf (" % s ", guest [I] time);
The count (*) + +;
}

Void Search (int count)
{int I, num, flag=1;
Printf (" please enter a number to query: ");
The scanf (" % d ", & amp; Num);
for(i=0; iIf (guest [I] num==num)
{printf (" \ n \ n name: % s ", guest [I] name);
Printf (" \ n number: % d ", guest [I] sum);
Printf (" meal time: % s \ n ", guest [I] time);
flag=0;
}
The else
Printf (" \ n \ n not query to the relevant information ");
}

Void the Update (int count)
{int I, num, flag=1;
Printf (" please enter a number: to change the name ");
The scanf (" % d ", & amp; Num);
for(i=0; iIf (guest [I] num==num)
{
Printf (" please input the number: ");
The scanf (" % d ", & amp; Guest [I] sum);
Printf (" please enter the meal time: ");
The scanf (" % s ", guest [I] time);
flag=0;
}
The else
Printf (" \ n't query to can modify the data! \n");
}
Void the Delete (int * count)
{int I, j, num, flag=1;
Printf (" please enter a name to delete number: ");
The scanf (" % d ", & amp; Num);
for(i=0; i<* count& & Flag; I++)
{if (guest [I] num==num)
{the for (j=I; J<* count - 1; J++)
Guest [j]=guest [j + 1);
flag=0;
The count (*) -;
}
The else
Printf (" \ n't can query to delete the data! \n");
}
}

Void Show (int count)
{int I;
printf("\n");
Printf (" code name and number of have dinner time \ n ");
for(i=0; i{printf (" % 4 d ", guest [I] num);
Printf (" % s ", guest [I] name);
Printf (" % 9 d, "guest [I] sum);
Printf (" % s \ n "12, guest [I] time);
}
}

Void Exit (void)
{
Printf (" already quit, welcome next time use, \ n ");
}

The results

CodePudding user response:

Can participate

CodePudding user response:

Several functions logic is flawed,
 # include 
#include

# define MaxSize 20

Struct guest_info {
char name[10];
Int sum;
Char time [10].
int num;
} guest [MaxSize];

Void Insert (int * count);
Void Search (int count);
Void the Update (int count);
Void the Delete (int * count);
Void Show (int count);
Void Exit (void);


Int main ()
{
int i;
int count=0;
Do
{printf (" \ n ");
Printf (" 1 -- order (Insert) \ n ");
Printf (" 2 -- query (Search) \ n ");
Printf (" 3 -- change order information (Update) \ n ");
Printf (" 4 - Delete orders (Delete) \ n ");
Printf (" 5 - shows reservation information (Show) \ n ");
Printf (" 6 - Exit (Exit) \ n ");
The scanf (" % d ", & amp; I);
The switch (I)
{case 1: Insert (& amp; The count);
break;
Case 2: Search (count);
break;
Case 3: the Update (count);
break;
Case 4: Delete (& amp; The count);
break;
Case 5: Show (count);
break;
Case 6: the Exit ();
break;
Default: printf (" wrong choice! Please re-election ");
}
} while (I!=6);//(I!=8)


return 0;
}

Void Insert (int * count)
{
Int I, in_num;
If the count (*==MaxSize)
{printf (" the space is full!" ); return ; }
Printf (" please enter a number: ");
The scanf (" % d ", & amp; In_num);
for(i=0; i<* count; I++)
If (guest [I] num==in_num)
{printf (" has the same number, please operate again, \ n "); return ; }
Guest [I] num=in_num;
Printf (" please input your name: ");
The scanf (" % s ", guest [I] name);
Printf (" please enter a number: ");
The scanf (" % d ", & amp; Guest [I] sum);
Printf (" please enter the meal time: ");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related