當前位置:編程學習大全網 - 編程語言 - C語言程序設計題目:編寫模擬同學排隊打飯程序

C語言程序設計題目:編寫模擬同學排隊打飯程序

代碼: #include"stdio.h"

#include"stdlib.h"

#include"conio.h"

#include"string.h"

#include"io.h"

#define ESC 27

#define ENTER 13

#define Y 89

#define y 121

#define N 78

#define n 110

void vmenu1();

char choose();

void password();

char *getps();

void mimam();

void build();

void save();

void buy();

void open1();

void modify();

void modifyM();

void XnumM();

void XclassM();

void XnameM();

void add();

void xuehaoA();

void xingmingA();

void query();

void xuehaoQ();

void xingmingQ();

void delete1();

void xuehaoD();

void xingmingD();

void sort();

void sortX();

void sortN();

void sortA();

void all();

void help();

void lock();

void exit1();

struct record

{

char cnumber[15];

char cclass[15];

char cname[15];

char cmoney[10];

char cspend[10];

struct record *next;

};

struct sot

{

char ccnumber[15];

struct sot *pnext;

};

struct address

{

char *adss;

struct address *anext;

};

struct sot *chead=NULL;

struct record *head=NULL,*ppointer=NULL,*temp;

struct record *modf;

struct address *ahead=NULL;

FILE *fp;

int Fflag=0;

int counts=0;

int loop=0;

void main()

{

char menu;

password();

while(loop==0)

{

system("CLS");

vmenu1();

menu=choose();

switch(menu)

{

case '1':build();break;

case '2':count++;

if(count==1)

{

buy();

break;

}

else

{

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;

case 'b':help();break;

case 'c':lock();break;

case 'd':{loop=1;exit1();break;}

default:

printf("----------------------------請輸入菜單上的序號 ------------------------\n");

printf("---------------------------按任意鍵重新開始選擇 -----------------------\n");

fflush(stdin);

a=getch();

}

}

}

void password()

{

char password[15];

char *password1;

char *password2;

char p1[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\t歡迎使用學生打飯系統!\n\n");

printf("\n");

printf("\n----------------------------請創建管理員密碼:--------------------------------\n");

password1=getps();

for(i=0;i<15;i++)

p1[i]=*(password1++);

printf("\n");

printf("\n----------------------------請再輸入壹次密碼:--------------------------------\n");

password2=getps();

for(i=0;i<15;i++)

p2[i]=*(password2++);

if(!strcmp(p1,p2))

{

if((fp=fopen("c:\\mima.txt","w"))==NULL)

{

printf("錯誤!\n");

exit(0);

}

else

{

fprintf(fp,"%s",p1);

printf("\n密碼創建完畢!\n");

fclose(fp);

system("cmd.exe /c attrib c:\\mima.txt +h");

break;

}

}

else

{

printf("兩次輸入不壹致,請重新輸入密碼:\n");

}

}

}

else

{

while(1)

{

count++;

for(i=0;i<5;i++)

printf("\n");

printf("----------------------------請輸入管理員密碼:----------------------------------\n");

password1=getps();

for(i=0;i<15;i++)

p1[i]=*(password1++);

if((fp=fopen("c:\\mima.txt","r"))==NULL)

{

printf("錯誤!\n");

exit(0);

}

else

{

fscanf(fp,"%s",password);

fclose(fp);

if(!strcmp(p1,password))

break;

else

printf("\n密碼錯誤!\n");

}

if(count<=9)

{

printf("\n您還有%d次機會。。。。。。\n",10-count);

printf("\n\n\n-------------------請按除ESC外的任意按鍵重新輸入密碼!----------------------\n");

a=getch();

if(a==ESC)

exit(0);

}

if(count==10)

{

printf("\n\n您無權使用本系統!\n");

printf("按任意鍵退出。。。。。。\n");

fflush(stdin);

a=getch();

exit(0);

}

}

}

printf("\n\n\n是否要對密碼進行修改?\n");

printf("\t按Y或y更改,其余按鍵進入系統。\n");

fflush(stdin);

a=getchar();

if(a==Y||a==y)

{

mimam();

}

system("CLS");

for(i=0;i<5;i++)

printf("\n");

printf("\t\t歡迎使用學生打飯系統!\n\n");

printf(" ");

printf("\t\t按任意鍵進入系統。。。。。。\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);

}

  • 上一篇:酷狗音樂網頁版mp3歌曲壹鍵下載酷狗音樂MP3下載插件安裝和使用
  • 下一篇:什麽是加密狗,要如何使用加密狗,越具體越好
  • copyright 2024編程學習大全網