C programming topic: write a program to simulate students queuing for cooking.
# contains "stdlib.h"
# contains "conio.h"
# contains "string.h"
# contains "io.h"
# Define ESC 27
# Definition input 13
# define Y 89
# Define y 12 1
# Define N 78
# Definition number 1 10
void vmenu 1();
char choose();
void password();
char * getps();
void mimam();
void build();
void save();
void buy();
void open 1();
void modify();
void modify m();
void XnumM();
void XclassM();
void XnameM();
void add();
void xuehaoA();
void xing minga();
void query();
void xuehaoQ();
void xingmingQ()。
void delete 1();
void Xue haod();
void xing mingd();
void sort();
void sortX();
void sortN();
void sortA();
void all();
void help();
void lock();
void exit 1();
Structural record
{
char cn number[ 15];
char cclass[ 15];
char cname[ 15];
char cmoney[ 10];
char cs pend[ 10];
Structure record * next
};
Structural sot
{
char cc number[ 15];
struct sot * pnext
};
Structural address
{
Charles * ADS;;
Structure address * anext
};
struct sot * chead = NULL
struct record *head=NULL,*ppointer=NULL,* temp
Structure record * modf
Structure address * ahead = NULL
FILE * fp
int Fflag = 0;
int counts = 0;
int loop = 0;
void main()
{
Char menu;
password();
while(loop==0)
{
System ("CLS");
vmenu 1();
menu = choose();
Switch (menu)
{
Case "1":build (); Break;
Case "2": count++;
if(count== 1)
{
buy();
Break;
}
other
{
chead = NULL
buy();
Break;
}
Case 3: open1(); Break;
Case "4": modify (); k = 0; Break;
Case 6: Query (); Break;
Case "7": delete1(); Break;
case“9”:all(); Break;
Example "b": help (); Break;
case“c”:lock(); Break;
Case "d": {loop =1; exit 1(); Break; }
Default value:
Printf ("-Please enter the serial number on the menu ")
Printf ("-Press any key to start selection again-\ n ");
fflush(stdin);
a = getch();
}
}
}
Invalid password ()
{
Character password [15];
char * password 1;
char * password2
char p 1[ 15];
char p2[ 15];
char a;
int I;
int count = 0;
if(access("c:\\mima.txt ",00)! =0)
{
while( 1)
{
System ("CLS");
for(I = 0; I<5; i++)
printf(" \ n ");
Printf ("\ t \ tWelcome to the student meal system! \ n \ n ");
printf(" \ n ");
Printf ("\ n-Please create an administrator password:-.
password 1 = getps();
for(I = 0; I< 15; i++)
p 1[I]= *(password 1++);
printf(" \ n ");
Printf ("\ n-Please enter the password again:-.
password 2 = getps();
for(I = 0; I< 15; i++)
p2[I]= *(password 2++);
If (! strcmp(p 1,p2))
{
if((fp=fopen("c:\\mima.txt "," w"))==NULL)
{
Printf ("Error! \ n ");
Exit (0);
}
other
{
fprintf(fp," %s ",p 1);
Printf ("\ nPassword created! \ n ");
fclose(FP);
system(" cmd . exe/c attrib c:\ \ mima . txt+h ");
Break;
}
}
other
{
Printf ("The two entries are inconsistent, please re-enter the password: \ n");
}
}
}
other
{
while( 1)
{
count++;
for(I = 0; I<5; i++)
printf(" \ n ");
Printf ("-Please enter the administrator password:-.
password 1 = getps();
for(I = 0; I< 15; i++)
p 1[I]= *(password 1++);
if((fp=fopen("c:\\mima.txt "," r ")= = NULL)
{
Printf ("Error! \ n ");
Exit (0);
}
other
{
Fscanf(fp, "%s", password);
fclose(FP);
If (! Strcmp(p 1, password))
Break;
other
Printf ("\ nPassword error! \ n ");
}
if(count & lt; =9)
{
Printf ("\ nYou still have %d chances. . . . . . \n”, 10-count);
Printf ("\ n \ n \ n-Please press any key other than ESC to re-enter the password! -\ n ");
a = getch();
if(a==ESC)
Exit (0);
}
if(count== 10)
{
Printf ("\ n \ nYou are not authorized to use this system! \ n ");
Printf ("Press any key to exit. . . . . . \ n ");
fflush(stdin);
a = getch();
Exit (0);
}
}
}
Printf ("\ n \ n \ nDo you want to change the password? \ n ");
Printf ("\ tPress y or y to change, and the rest keys enter the system. \ n ");
fflush(stdin);
a = getchar();
if(a==Y||a==y)
{
mimam();
}
System ("CLS");
for(I = 0; I<5; i++)
printf(" \ n ");
Printf ("\ t \ tWelcome to the student meal system! \ n \ n ");
printf(" ");
Printf ("\ t \ tPress any key to enter the system. . . . . . \ n \ n ");
a = getch();
}
char *getps()
{
char p[ 15];
Password = p;;
while( 1)
{
fflush(stdin);
* password = getch();
if(*password==ENTER)
{
Break;
}
putchar(' * ');
password++;
}
* password = ' \ 0
Password = p;;
Return (password);
}