91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

使用C語言怎么實現一個外賣管理系統

發布時間:2021-04-17 16:34:43 來源:億速云 閱讀:300 作者:Leah 欄目:編程語言

使用C語言怎么實現一個外賣管理系統?相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。

功能模塊圖:

使用C語言怎么實現一個外賣管理系統

以下為函數調用關系圖:

使用C語言怎么實現一個外賣管理系統

以下為整個代碼:

#include<stdio.h>
#include<stdlib.h>
#include<string.h> 
#include<windows.h>
#include<time.h>
#include<conio.h>
void choose();
//建立關于店鋪的結構體 
typedef struct shop
{
  char name[20];
  char phone[20];
  char address[30];
  char password[20];
  struct shop *next;
}shop,*link_shop;
//建立關于訂單的結構體 
typedef struct food
{
  char name[20];
  int type;
  int amount;
  int price;
  int total;
  char shop[20];
  char yonghu[20];
  char leibie[20]; 
  struct food *next; 
}food,*link_food;
//建立關于用戶的結構體
typedef struct user
{
  char name[20];
  char delivery[39];
  char password[15];
  char number[15];
  int score;
  struct user *next;
}user,*link_user;
typedef struct money
{
  char person[20];
  char card[25];
  char mima[20];
  struct money *next;
}money,*link_money;
char yh[20];//用戶設置全局變量 
char dp[20];//店鋪設置全局變量 
time_t start,end;
//函數聲明
void foodwrite(link_food LF);
void shopwrite1(link_shop LS);
void dingdanwrite(link_food LF);
void user_moneywrite(link_user LM);
void welcome()
{
  int i=0;
  char a[52]="▲▼WELCOME TO RESTAURANT MANAGEMENT SYSTEM▲▼";
  //system("color 0a");
  printf("\n\n\n\n\t\t");
  while(a[i])
  {
    printf("%c",a[i]);
    Sleep(50);
    i++;
  }
  printf("\n\n\n\n\t\t");
}
void Exit()
{
  int i=0;
  system("cls");
  char a[20]="LOVE you,byebye^_^";
  system("color 03");
  printf("\n\n\n\t\t\t");
  while(a[i])
  {
    printf("%c",a[i]);
    Sleep(100);
    i++;
  }
}
void ME()
{
  system("color 0b");
  printf("\n\n\n\t\t☆★ W E L C O M E ☆★\n\n\t這里是外賣管理系統,請選擇接下來的操作:");
  printf("\n\n\t\t\t1.登陸");
  printf("\t\t\t2.注冊\t\t\t0.退出\n"); 
}
//主菜單(登陸或者注冊)  
void MENU()
{
  printf("\n\n\n\n\t\t\t\t\t================================\n");
  printf("\t\t\t\t\t   外 賣 管 理 系 統   \n");
  printf("\t\t\t\t\t     1.管理員登陸     \n");
  printf("\t\t\t\t\t     2.用戶登錄      \n");
  printf("\t\t\t\t\t     3.店家登陸      \n");
  printf("\t\t\t\t\t     0.返回上一級     \n");
  printf("\t\t\t\t\t================================\n");
}
//管理員選項 
void MENU1()
{
  system("color 0f");
  printf("                                     溫馨小提示:按5可以清屏哦^-^\n");
  printf("\n\n\t\t\t\t\t1.查看店鋪信息▲\n");
  printf("\t\t\t\t\t--------------\n");
  printf("\t\t\t\t\t2.店鋪信息修改▼\n");
  printf("\t\t\t\t\t--------------\n");
  printf("\t\t\t\t\t3.處理申請店鋪▲\n");
  printf("\t\t\t\t\t--------------\n");
  printf("\t\t\t\t\t4.修改本人信息▼\n");
  printf("\t\t\t\t\t--------------\n");
  printf("\t\t\t\t\t0.返回上一級 ▲\n");
}
//用戶選項 
void MENU2()
{
  system("color 0f");
  printf("\n\n\t\t\t\t 1.用戶相關 ▲\t\t\t 5.購買菜品 ▼\n"); 
  printf("\t\t\t\t---------------\t\t\t---------------\n");
  printf("\t\t\t\t 2.查看訂單 ▲\t\t\t 6.訂單排序▼\n");
  printf("\t\t\t\t---------------\t\t\t---------------\n");
  printf("\t\t\t\t 3.查看菜品 ▲\t\t\t 0.返回上級 ▼\n");
  printf("\t\t\t\t---------------\t\t\t---------------\n");
  printf("\t\t\t\t 4.修改訂單 ▲\n");
}
//店主選項 
void MENU3()
{
  system("color 0f");
  printf("\n\n\n\t\t\t ________ Shop Version _______\n");
  printf("\t\t\t|               |\n");
  printf("\t\t\t|     1.添加菜品     |\n");
  printf("\t\t\t|     2.修改菜品     |\n");
  printf("\t\t\t|     3.刪除菜品     |\n");
  printf("\t\t\t|     4.查看菜品     |\n");
  printf("\t\t\t|     5.查看業績     |\n");
  printf("\t\t\t|     0.返回上一級    |\n");
  printf("\t\t\t|_____________________________|\n");
}
//建立關于單鏈表
void *creatf()
{
  int i=0,n;
  link_food LF;
  food *s,*r;
  char a[10];
  //srand((unsigned)time(NULL));//產生隨機數的種子 
  LF=(food *)malloc(sizeof(food));
  LF->next=NULL;
  r=LF;
  while(1)
  {
    printf("請輸入菜的名稱:");
    scanf("%s",a);
    if(strcmp(a,"0")!=0)
    {
      s=(food *)malloc(sizeof(food));
      printf("請輸入菜的單價:");
      scanf("%d",&s->price);
      printf("請輸入菜的類別");
      scanf("%s",s->leibie); 
      strcpy(s->name,a);
      s->total=(s->amount)*(s->price);
      r->next=s;
      s->next=NULL;
      r=s;
    } 
    else
      break;
  }
  foodwrite(LF); 
} 
shop *creats()
{
  char a[30],b[20],c[15],d[20];
  link_shop LS;
  shop *s,*r;
  LS=r=(shop *)malloc(sizeof(shop));
  LS->next=NULL;
  r=LS;
  while(1)
  {
    printf("請輸入店鋪信息:\n");
    printf("\t\t●  店鋪名稱:");
    scanf("%s",a);
    printf("\n\t\t●  店鋪電話:");
    scanf("%s",b);
    if(strcmp(b,"0")!=0)
    {
      printf("\n\t\t●  店鋪地址:"); 
      scanf("%s",c);
      printf("\n\t\t●  店鋪密碼:"); 
      scanf("%s",d);
      s=(shop *)malloc(sizeof(shop));
      strcpy(s->name,a);
      strcpy(s->phone,b);
      strcpy(s->address,c);
      strcpy(s->password,d);
      r->next=s;
      s->next=NULL;
      r=s;
    }
    else
      break;
  }
  return LS; 
}
void Outputshop(link_shop Ls)
{
  int n=0;
  shop *p,*u;
  p=Ls->next;
  system("cls");
  printf("入駐的商家如下:\n");
  printf("\t\t\t\t-------------------------------------------\n");
  printf("\t\t\t\t店鋪名稱\t店鋪電話\t店鋪地址\n");
  printf("\t\t\t\t-------------------------------------------\n");
  while(p)
  {
    printf("\t\t\t\t%8s\t%8s\t%7s\n",p->name,p->phone,p->address);
    printf("\t\t\t\t-------------------------------------------\n");
    p=p->next;
  }
  for(u =Ls->next; u != NULL;u = u->next) 
    n++;
  printf("\t\t\t\t合計\t\t\t\t%d個\n",n);
  printf("\t\t\t\t-------------------------------------------\n");
}
void Outputfood(link_food LF)
{
  food *s;
  s=LF->next;
  int sum=0;
  printf("訂單如下:\n");
  printf("\t----------------------------------------------------------------------------------------------------\n");
  printf("\t菜名\t\t數量/份\t\t單價/元\t\t總價/元\t\t店鋪\t\t訂單號\t\t用戶名\n"); 
  printf("\t----------------------------------------------------------------------------------------------------\n");
  for(s=LF->next;s!=NULL;s=s->next)
  {
    if(strcmp(s->yonghu,yh)==0)
    {
      printf("\t%-8s\t%-8d\t%-8d\t%-8d\t%-10s\t%-10d\t%s\n",s->name,s->amount,s->price,s->total,s->shop,s->type,s->yonghu);
      printf("\t----------------------------------------------------------------------------------------------------\n");
      sum=sum+s->total;
    }
  }
  printf("\t累計輸出/元\t\t\t\t\t\t\t%d\n",sum);
  printf("\t----------------------------------------------------------------------------------------------------\n");
  if(sum==0)
  { 
    printf("○  您還沒有訂單呢,快去購買吧 φ(>ω<*) ");
    printf("\n\t\t\t\t\t->");
    Sleep(1000);
    printf("->");
    Sleep(1000);
    printf("->");
    Sleep(1000);
    system("cls");
    MENU2();
    return;
  }
}
void outputfood(link_food LF)
{
  food *p;
  p=LF->next;
  printf("\n\t\t\t         菜    譜            "); 
  printf("\n\t\t\t--------------------------------------------------\n");
  printf("\t\t\t菜名    菜價     店鋪      菜系\n"); 
  printf("\t\t\t---------------------------------------------------\n");
  while(p)
  {
    printf("\t\t\t%-13s%-12d%-14s%s\n",p->name,p->price,p->shop,p->leibie);
    printf("\t\t\t---------------------------------------------------\n");
    p=p->next;
  }
}
//充值
user* addmoney(user *u)
{
  int n;
  char y;
  char a[20];
  FILE *fp;
  link_money LY;
  money *p,*r;
  printf("您賬戶里的余額為:%d",u->score);
  printf("是否充值?Y/else");
  fflush(stdin);//清除緩存 
  y=getchar();
  if(y=='Y')
  {
    fp=fopen("yue.txt","rt");
    LY=r=(money *)malloc(sizeof(money));
    LY->next=NULL;
    while(!feof(fp))
    {
      p=(money *)malloc(sizeof(money));
      fscanf(fp,"%s %s %s\n",p->person,p->card,p->mima);
      p->next=NULL;
      r->next=p;
      r=p; 
    }    
    fclose(fp);
    p=LY->next;
    while(1)
    {
      if(strcmp(yh,p->person)==0)
      {
        break;
      }
      else
        p=p->next; 
    }
    printf("充值的錢數?");
    scanf("%d",&n);
    printf("請輸入支付密碼:");
    scanf("%s",a);
    if(strcmp(p->mima,a)==0)
    {
      u->score=(u->score+n); 
      printf("已充值");
    } 
    else
      printf("\t\t×  密碼錯誤,充值失敗");
  }
  else
    printf("已放棄充值");
  return u; 
}          
//按工號排序
void name_sort(link_shop LS) 
{ 
  int i,j,n; 
  n = 0; //記錄店鋪總數;
  shop *u,*q,*p;
  for(u =LS->next; u != NULL;u = u->next) 
    n++; 
//采用冒泡法對各個節點按姓名升序
  for(i=1;i<=n;i++) 
  { 
    u =LS; 
    for(j=0;j<n-i;j++) 
    { 
      p = u->next; 
      q = p->next; 
      if(strcmp(p->name,q->name) > 0 || strcmp(p->name,q->name) == 0) 
      { 
        u->next = q; 
        p->next = q->next; 
        q->next = p; 
      } 
      u = u->next; 
    } 
  } 
  printf("\t排序后店鋪信息\n");
  Outputshop(LS);
  return;
}
void address_sort(link_shop LS) 
{ 
  int i,j,n; 
  n = 0; //記錄店鋪總數;
  shop *u,*q,*p;
  for(u =LS->next; u != NULL;u = u->next) 
    n++; 
//采用冒泡法對各個節點按地址升序
  for(i=1;i<=n;i++) 
  { 
    u =LS; 
    for(j=0;j<n-i;j++) 
    { 
      p = u->next; 
      q = p->next;
      if(strcmp(p->address,q->address) > 0 || strcmp(p->address,q->address) == 0) 
      { 
        u->next = q; 
        p->next = q->next; 
        q->next = p; 
      } 
      u = u->next; 
    } 
  } 
  printf("\t\t\t\t地址排序后店鋪信息\n");
  Outputshop(LS);
  return;
}
void dingdan_name_sort(link_food LF) //按訂單食物名稱排序 
{ 
  int i,j,n; 
  n = 0; //記錄店鋪總數;
  food *u,*q,*p;
  for(u =LF->next; u != NULL;u = u->next) 
    n++; 
//采用冒泡法對各個節點按姓名升序
  for(i=1;i<=n;i++) 
  { 
    u =LF; 
    for(j=0;j<n-i;j++) 
    { 
      p = u->next; 
      q = p->next; 
      if(strcmp(p->name,q->name) > 0 || strcmp(p->name,q->name) == 0) 
      { 
        u->next = q; 
        p->next = q->next; 
        q->next = p; 
      } 
      u = u->next; 
    } 
  } 
  Outputfood(LF);
  return;
}
void dingdan_total_sort(link_food LF) //按訂單總價從高到低排序 
{ 
  int i,j,n; 
  n = 0; //記錄店鋪總數;
  food *u,*q,*p;
  for(u =LF->next; u != NULL;u = u->next) 
    n++; 
//采用冒泡法對各個節點按姓名升序
  for(i=1;i<=n;i++) 
  { 
    u =LF; 
    for(j=0;j<n-i;j++) 
    { 
      p = u->next; 
      q = p->next; 
      if(p->total>q->total) 
      { 
        u->next = q; 
        p->next = q->next; 
        q->next = p; 
      } 
      u = u->next; 
    } 
  } 
  Outputfood(LF);
  return;
}
void dingdandelete(link_food Lf)
{
  food *p,*n;
  p=Lf;
  n=p->next;
  int m;
  char a;
  printf("請輸入你所想刪除的訂單序號:");
  scanf("%d",&m);
  while(n)
  {
    if(m==n->type)
    {
      if(strcmp(n->shop,dp)==0)
      {
        p->next=n->next;
        //foodwrite(Lf);
        dingdanwrite(Lf);
        break; 
      }
      else
        printf("不好意思,您沒有權限刪除\n");
      break;
    }
    else
    {
      p=p->next;
      n=n->next;
    }
  }
}
food *dingdanread()
{
  FILE *fp;
  link_food LF,r,s;
  fp=fopen("dingdan.txt","rt");
  if(fp==NULL)
  { 
    printf("查看訂單失敗");
    return 0;
  }
  LF=r=(food *)malloc(sizeof(food));
  r->next=NULL;
  while(!feof(fp))
  {
    s=(food *)malloc(sizeof(food)); 
    fscanf(fp,"%s %d %d %d %s %d %s\n",s->name,&s->amount,&s->price,&s->total,s->shop,&s->type,s->yonghu);
    r->next=s;
    s->next=NULL;
    r=s;
  }
  return LF;
}
void scorefind(link_food LF)
{
  int sum=0;
  food *p;
  p=LF->next;
  system("cls"); 
  printf("\n\n\n\t\t\t產生的訂單如下:\n");
  printf("   ----------------------------------------------------------------------------------------------------\n");
  printf("   菜品名稱 \t菜品數量\t菜品單價\t菜品總價\t店鋪名稱\t訂單號 \t\t用戶名\n");
  printf("   ----------------------------------------------------------------------------------------------------\n");
  while(p)
  {
    if(strcmp(p->shop,dp)==0)
    {
    printf("  %7s%14d%15d%16d%16s%15d%18s\n",p->name,p->amount,p->price,p->total,p->shop,p->type,p->yonghu);
    printf("   ----------------------------------------------------------------------------------------------------\n");
    sum=sum+p->total;
    }
    p=p->next;
  }
  printf("   合計/元:\t\t\t\t\t\t\t累計收入%d\n",sum);
  printf("   ----------------------------------------------------------------------------------------------------\n");
  if(sum==0)
    printf("\t\t●  您店里的菜還沒有人購買哦,應該反思啦\n");
}
food * foodread()//讀取 
{
  link_food LF;
  food *s,*r;
  LF=r=(food *)malloc(sizeof(food));
  LF->next=NULL;
  FILE *fp;
  fp=fopen("food.txt","rt");
  if(fp==NULL)
  {
    printf("不能打開此文件");
    exit(1); 
  }
  while(!feof(fp))//判斷文件指針是否處于文件結束位置,若是,返回1,非,返回0 
  {
    s=(food *)malloc(sizeof(food)); 
    fscanf(fp,"%s %d %s %s\n",s->name,&s->price,s->shop,s->leibie);
    r->next=s;
    s->next=NULL;
    r=s;
  }
  fclose(fp);
  return LF; 
 }
money * moneyread()//讀取 
{
  link_money LM;
  money *s,*r;
  LM=r=(money *)malloc(sizeof(money));
  LM->next=NULL;
  FILE *fp;
  fp=fopen("yue.txt","rt");
  if(fp==NULL)
  {
    printf("不能打開此文件");
    exit(1); 
  }
  while(!feof(fp))//判斷文件指針是否處于文件結束位置,若是,返回1,非,返回0 
  {
    s=(money *)malloc(sizeof(money));  
    fscanf(fp,"%s %s %s\n",s->person,s->card,s->mima);
    r->next=s;
    s->next=NULL;
    r=s;
  }
  fclose(fp);
  return LM; 
 }
shop * shopread()
{
  link_shop LS;
  shop *s,*r;
  LS=r=(shop *)malloc(sizeof(shop));
  r->next=NULL;
  FILE *fp;
  fp=fopen("shop.txt","rt");
  if(fp==NULL)
  {
    printf("不能打開此文件");
    exit(1); 
  }
  while(!feof(fp))//判斷文件指針是否處于文件結束位置,若是,返回1,非,返回0 
  {
    s=(shop *)malloc(sizeof(shop));
    s->next=NULL;
    fscanf(fp,"%s %s %s %s\n",s->name,s->phone,s->address,s->password);
    r->next=s;
    r=s;
  }
  fclose(fp);
  return LS; 
 }
user * userread()
{
  link_user LU;
  user *s,*r;
  LU=r=(user *)malloc(sizeof(user));
  r->next=NULL;
  FILE *fp;
  fp=fopen("users.txt","rt");
  if(fp==NULL)
  {
    printf("不能打開此文件");
    exit(1); 
  }
  while(!feof(fp))//判斷文件指針是否處于文件結束位置,若是,返回1,非,返回0 
  {
    s=(user *)malloc(sizeof(user));
    s->next=NULL;
    fscanf(fp,"%s %s %s %s %d\n",s->name,s->delivery,s->password,s->number,&s->score);
    r->next=s;
    r=s;
  }
  fclose(fp);
  return LU; 
 } 
void deleteshop(link_shop LS)
{
  int i=0;
  shop *p,*q;
  p=LS;
  q=p->next;
  char m[20];
  char a;
  printf("請輸入你所想刪除的店鋪名稱或者電話:");
  scanf("%s",m);
  while(q)
  {
    if(strcmp(m,q->name)==0||strcmp(m,q->phone)==0)
    {
      i++;
      p->next=q->next;
      shopwrite1(LS);
      return;
    }
    else
    {
      p=p->next;
      q=q->next;
    }
  }
  if(i==0)
  {
    printf("沒有此店鋪,無法刪除\n");
    return;
  }
}
void deletedingdan(link_food Lf)
{
  food *p,*n;
  p=Lf;
  n=p->next;
  int m,i=0;
  char a;
  printf("請輸入你所想刪除的訂單號:");
  scanf("%d",&m);
  while(n)
  {
    if(n->type==m)
    {
      if(strcmp(n->yonghu,yh)==0)
      {
        p->next=n->next;
        i++;
        foodwrite(Lf);
      }
      else
        printf("不好意思,您沒有權限刪除\n");
      break;
    }
    else
    {
      p=p->next;
      n=n->next; 
    }
  }
  if(i==0)
  {
    printf("\t沒有此訂單,無法刪除\n");
    return;
  }
}
void purchase()
{
  link_food Lf;
  money *LM,*mo;
  user *lu,*us;
  FILE *fp;
  char a[20],b[20],mi[20];
  char y;
  int i=0;
  printf("\t\t◇您想吃啥呢?");
  scanf("%s",a);
  Lf=foodread();
  food *p;
  p=Lf->next;
  srand((unsigned)time(NULL));//訂單號的種子 
  while(p!=NULL)
  {
    if(strcmp(p->name,a)==0||strcmp(p->leibie,a)==0)
    {
    // printf("%s\t%d\t%s\n",p->name,p->price,p->shop);
      i++;
    }  
    p=p->next; 
  }
  if(i==0)
  {
    printf("\t\t\t×不好意思,還沒有此菜呢\n");
    system("pause");
    system("cls");
    MENU2();
    return; 
  }
  else
  {
    p=Lf->next;
    printf("\n\t\t\t--------------------------------------------------\n");
    printf("\t\t\t菜名    菜價     店鋪      菜系\n"); 
    printf("\t\t\t---------------------------------------------------\n");
    while(p)
    {
      if(strcmp(p->leibie,a)==0||strcmp(p->name,a)==0)
      {
        printf("\t\t\t%-13s%-12d%-14s%s\n",p->name,p->price,p->shop,p->leibie);
        printf("\t\t\t---------------------------------------------------\n");
      }

      p=p->next;
    }
  }
  printf("\t\t◇請輸入要購買的店鋪:");
  scanf("%s",b);
  lu=userread();
  us=lu->next;
  while(us)
  {
    if(strcmp(yh,us->name)==0)
      break;
    else
      us=us->next;
  }//找出要購買的用戶信息 
  LM=moneyread();
  mo=LM->next;
  i=0;
  while(mo)
  {
    if(strcmp(yh,mo->person)==0)
    {
      i++;
      break;
    }

    else
      mo=mo->next;
  }//找出用戶的銀行卡信息 
  if(i==0)
  {
    printf("\t\t×  您還沒有綁定銀行卡哦,不能購買的");
    return; 
  }
  p=Lf->next;
  i=0;
  while(p)
  {
    if(strcmp(p->name,a)==0||strcmp(p->leibie,a)==0)
    {
      if(strcmp(p->shop,b)==0)
      {
        printf("\t\t◇請輸入要購買的數量");
        scanf("%d",&p->amount);
        if(p->amount!=0)
        {
          i++;
          p->total=(p->amount)*(p->price);
          p->type=rand()%900+100;
          if((us->score)<p->total)
          {
            printf("\t\t×  您的賬號余額不足,請先充值\n");
            system("pause");
            system("cls");
            MENU2();
            return;
          }
          printf("\t\t●確認購買?Y/else");
          fflush(stdin);
          y=getchar();
          if(y=='Y')
          {
            printf("請輸入支付密碼:");
            scanf("%s",mi);
            if(strcmp(mi,mo->mima)==0)
            {
              fp=fopen("dingdan.txt","at");
              if(fp==NULL)
                printf("\t\t\t\t×購買失敗\n");//因文件無法打開而失敗
              else
              {
                fprintf(fp,"%s %d %d %d %s %d %s\n",p->name,p->amount,p->price,p->total,p->shop,p->type,yh);
                fclose(fp);
                us->score=(us->score)-(p->total);
                user_moneywrite(lu);
                printf("\t\t\t\t√購買成功,請耐心等待配送\n");
                start = time(NULL);//計時 
                system("pause");
                system("cls");
                MENU2();
                return;
              }    
            }
            else
            {
              printf("\t\t×  密碼錯誤,購買失敗");
              system("pause");
              system("cls");
              MENU2();
              return; 
            }    
          } 
          else
          {
            printf("\t\t\t×已放棄購買");
            system("pause");
            system("cls");
            MENU2();
            return; 
          }
        }
        else
        {
          printf("\t\t\t×請輸入正確的數量");
          system("pause");
          system("cls");
          MENU2();
          return; 
        }
      }
    }
    p=p->next;
  }
  if(i==0)
  {
    printf("\t\t×請輸入表中的店鋪名稱哦\n");
    system("pause");
    system("cls");
    MENU2(); 
  }
}
void foodwrite(link_food LF)//保存 
 {
  FILE *fp;
  food *p;
  char a;
  printf("確認保存?(Y/else)");
  scanf("%*c%c",&a);
  if(a=='Y')
  {
    fp=fopen("food.txt","at");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LF->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %d %s %s\n",p->name,p->price,dp,p->leibie);
    printf("修改成功\n");
    fclose(fp);
    return;
  }
  else
    printf("已放棄修改");
 }
 void foodwrite1(link_food LF)
 {
  FILE *fp;
  food *p;
  char a;
  printf("確認保存?(Y/else)");
  scanf("%*c%c",&a);
  if(a=='Y')
  {
    fp=fopen("food.txt","wt");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LF->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %d %s %s\n",p->name,p->price,p->shop,p->leibie);
    printf("修改成功\n");
    fclose(fp);
    return;
  }
  else
    printf("已放棄修改");
 }
// void foodwrite2(link_food LF)
// {
// FILE *fp;
// food *p;
// char a;
// printf("確認保存?(Y/else)");
// scanf("%*c%c",&a);
// if(a=='Y')
// {
//   fp=fopen("food.txt","wt");
//   if(fp==NULL)
//     printf("錯誤!無法打開");
//   for(p=LF->next;p!=NULL;p=p->next)
//     fprintf(fp,"%s %d %s %s\n",p->name,p->price,p->shop,p->leibie);
//   printf("修改成功\n");
//   fclose(fp);
//   return;
// }
// else
//   printf("已放棄修改");
// }
 void dingdanwrite(link_food LF)
 {
  FILE *fp;
  food *p;
  char a;
  printf("確認保存?(Y/else)");
  scanf("%*c%c",&a);
  if(a=='Y')
  {
    fp=fopen("dingdan.txt","wt");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LF->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %d %d %d %s %d %s\n",p->name,p->amount,p->price,p->total,p->shop,p->type,p->yonghu);
    printf("修改成功\n");
    fclose(fp);
    return;
  }
  else
    printf("已放棄修改"); 
 }
void shopwrite1(link_shop LS)
 {
  FILE *fp;
  shop *p;
  char a;
  printf("確認保存?(Y/else)");
  scanf("%*c%c",&a);
  if(a=='Y')
  {
    fp=fopen("shop.txt","wt");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LS->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %s %s %s\n",p->name,p->phone,p->address,p->password);
    printf("保存成功\n");
    fclose(fp);
    return;
  }
  else
    printf("已放棄");
 }
 void shopwrite2(link_shop LS)
 {
  FILE *fp;
  shop *p;
  char a;
  printf("是否將信息保存至文件里?(Y/else)");
  scanf("%*c%c",&a);
  if(a=='Y')
  {
    fp=fopen("shop.txt","at");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LS->next;p!=NULL;p=p->next)
    fprintf(fp,"%s %s %s\n",p->name,p->phone,p->address);
    printf("修改成功\n");
    fclose(fp);
    return;
  }
  else
    printf("已放棄修改");

 }
 void userwrite(link_user LU)
 {
  FILE *fp;
  user *p;
  char a;
// printf("請確認?(Y/else)");
// scanf("%*c%c",&a);
// if(a=='Y')
// {
    fp=fopen("users.txt","wt");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LU->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %s %s %s %d\n",p->name,p->delivery,p->password,p->number,p->score);
    printf("操作成功\n");
    fclose(fp);
    return;
// }
  //else
    //printf("已放棄注冊");
 }
 void user_moneywrite(link_user LM)
 {
  FILE *fp;
  user *p;
  char a;
// printf("是否將信息保存至文件里?(Y/else)");
// scanf("%*c%c",&a);
// if(a=='Y')
// {
    fp=fopen("users.txt","wt");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LM->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %s %s %s %d\n",p->name,p->delivery,p->password,p->number,p->score);
    //printf("注冊成功\n");
    fclose(fp);
    //return;
// }
  //else
    //printf("已放棄注冊");
 }
 void userwrite2(link_user LU)
 {
  FILE *fp;
  user *p;
  char a;
  printf("是否將信息保存至文件里?(Y/else)");
  scanf("%*c%c",&a);
  if(a=='Y')
  {
    fp=fopen("users.txt","at");
    if(fp==NULL)
      printf("錯誤!無法打開");
    for(p=LU->next;p!=NULL;p=p->next)
      fprintf(fp,"%s %s %s %s %d\n",p->name,p->delivery,p->password,p->number,p->score);
    printf("注冊成功\n");
    fclose(fp);
    return;
  }
  else
    printf("已放棄注冊");
 }
void increaseshop(link_shop LS)
{
  char a[30],b[20],c[15],d[20];
  shop *s;
  printf("請輸入你所想加入的店鋪信息:\n");
  printf("\t\t●  店鋪名稱:");
  scanf("%s",a);
  printf("\n\t\t●  店鋪電話:");
  scanf("%s",b);
  printf("\n\t\t●  店鋪地址:"); 
  scanf("%s",c);
  printf("\n\t\t●  店鋪密碼:"); 
  scanf("%s",d);
  if(strcmp(a,"0")!=0)
  {
    s=(shop *)malloc(sizeof(shop));
    strcpy(s->name,a);
    strcpy(s->phone,b);
    strcpy(s->address,c);
    strcpy(s->password,d);
  }
  s->next=LS->next;
  LS->next=s; 
  shopwrite1(LS);
 }
void shopfind(link_shop LS)
{ 
  shop *p;
  char E[20];
  p=LS->next;
  printf("請輸入店鋪的名稱:");
  scanf("%s",E); 
  while(strcmp(p->name,E)!=0&&(p->next)!=NULL)
  {
    p=p->next;
  }
  if((p->next)==NULL)
  {
    printf("沒有此店鋪");
    return;
  }  
  printf("您所查詢的店鋪信息為:\n名稱\t電話\t地址\n");
  printf("%s %s %s",p->name,p->phone,p->address);
} 
void registerdeal()
{
  int q;
  FILE *fp;
  char y;
  link_shop head;
  shop *r,*p;
  head=r=(shop *)malloc(sizeof(shop));
  r->next=NULL;
  fp=fopen("shenqing.txt","rt");
  if(fp==NULL)
  {
    printf("發生錯誤,無法打開文件");
    return; 
  }
  if((y=fgetc(fp))==EOF)
  {
    printf("目前沒有需要處理的信息\n");
    system("pause");
    system("cls");
    MENU1();
    return;
  }
  else
  {
    while(!feof(fp))
    {
      p=(shop *)malloc(sizeof(shop));
      fscanf(fp," %s %s %s %s \n",p->name,p->phone,p->address,p->password);
      r->next=p;
      p->next=NULL;
      r=p;
    }
    for(p=head->next;p!=NULL;p=p->next)
      printf("%s %s %s\n",p->name,p->phone,p->address); 
    printf("是否同意注冊?Y/else");
    scanf("%*c%c",&y); 
    if(y=='Y')
    {
      fp=fopen("shop.txt","at");
      if(fp==NULL)
        printf("文件不存在,打開錯誤\n"); 
      for(p=head->next;p!=NULL;p=p->next)
        fprintf(fp,"% s %s %s %s \n",p->name,p->phone,p->address,p->password);
      fclose(fp);
    } 

  } 
  printf("處理成功"); 
  fp=fopen("shenqing.txt","wt");
  fclose(fp);
}
void MENU1_choose()
{
  int n,m,q;
  char a[20],b[20],c[20],d[20];
  char y;
  FILE *fp,*fa;
  shop *p;
  shop sq;
  link_shop LS;
  link_user LU;
  LS=shopread();
  while(1)
  {
    printf("請選擇你想所想進行的選項:\n"); 
    scanf("%d",&n);
    if(n==1)
    {
      Outputshop(LS);
      printf("是否進行排序?Y/else");
      fflush(stdin);
      y=getchar();
      if(y=='Y')
      {
        system("cls");
        printf("\n\n\n\t\t\t●1.按店鋪名稱排序\n");
        printf("\t\t\t●2.按店鋪地址排序\n");
        scanf("%d",&m);
        if(m==1)
          name_sort(LS);
        if(m==2)
          address_sort(LS);
        printf("1.退出\t2.返回");
        scanf("%d",&m);
        if(m==1)
          exit(0);
        else
        {
          system("cls");
          MENU1();
          continue;
        } 
      }
      else
      {
        printf("已放棄排序\n");
        system("cls");
        MENU1();
      }

    }
    if(n==2)
    {
      system("cls");
      printf("\n\n\n\t\t\t☆【1】刪除店鋪\n");
      printf("\t\t\t☆【2】增加店鋪\n");
      printf("\t\t\t☆【3】輸入店鋪\n");
      printf("\t\t\t☆【0】返回上一級\n");
      printf("\n\t\t請選擇將要進行的操作:\n"); //二級 
      while(1)
      {
        scanf("%d",&m);
        if(m==1)
          deleteshop(LS);
        if(m==2)
          increaseshop(LS);
        if(m==3)
        { 
          LS=creats();
          shopwrite1(LS);
        }
        if(m==4)
          shopfind(LS);  
        if(m==0)
        {
          system("cls");
          MENU1();
          break;
        } 
      }    
    }
    if(n==3)
      registerdeal();//注冊處理以及投訴處理函數 
    if(n==4)
    {
      //LU=userread();
      system("cls");
      printf("\n\t請選擇所想進行的選項:\n\n");
      printf("\t● ○ ● ○ ● ○ ●\n");
      printf("\t  1.查看個人信息  \n");
      printf("\t○ 2.修改個人信息 ○\n");
      printf("\t  0.返回上一級   \n");//二級 
      printf("\t● ○ ● ○ ● ○ ●\n");
      while(1)
      {
        scanf("%d",&m);
        if(m==1)
        {
          char d[20];
          fa=fopen("admin.txt","rt");
          fscanf(fa,"%s %s %s %s",a,b,c,d);
          fclose(fa);
          printf("\n\t\t地區\t姓名\t電話號碼\n");
          printf("\t\t%s\t%s\t%s\n",a,b,d);
        }
        if(m==2)
        {
          system("cls");
          printf("\n                             溫馨提示,按0返回哦(〃'▽'〃)\n"); 
          printf("\n\t\t● ○ ● ○ ● ○ ●\n");
          printf("\t\t   1.修改姓名   \n");
          printf("\t\t○  2.修改地址  ○\n");
          printf("\t\t   3.修改密碼   \n");//三級 
          printf("\t\t● ○ ● ○ ● ○ ●\n");
          scanf("%d",&q); 
          if(q==1)
          {
            printf("請輸入新的姓名:\n");
            scanf("%s",b);
          }
          if(q==2)
          {
            printf("請輸新的地址:\n");
            scanf("%s",a); 
          } 
          if(q==3)//修改密碼,含找回密碼 
          {
            int j=0,h; 
            char f[20],e[20];
            fa=fopen("admin.txt","rt");
            fscanf(fa,"%s %s %s %s",a,b,c,d);
            printf("您需要輸入舊的密碼:\n");
            scanf("%s",f);
            while(strcmp(f,c)!=0)
            {
              j++; 
              printf("\t\t×您的密碼有誤,請重新輸入:");
              scanf("%s",f);
              if(j==2)
              {
                printf("\t\t×您已經連續輸錯三次,按1找回密碼,其他數字鍵返回:");
                scanf("%d",&j);
                if(j==1)
                {
                  printf("請輸入您的電話號碼:");
                  scanf("%s",e);
                  if(strcmp(e,d)==0)
                  {
                    srand((unsigned)time(NULL));
                    j=rand()%900+100;
                    fp=fopen("yanzheng.txt","wt");
                    //fscanf(fp,"%d\n",&j);
                    fprintf(fp,"%d\n",j);
                    fclose(fp);
                    printf("我們已經發送驗證碼到您的手機,請輸入:");
                    scanf("%d",&h);
                    if(h==j)
                    {
                      printf("\t\t√請重新設置您的密碼:");
                      scanf("%s",c);
                      break; 
                    }
                    else
                    {
                      printf("\t\t×驗證碼錯誤\n");
                      break; 
                    }
                  }
                  else
                  {
                    printf("\t\t×找回密碼失敗\n");
                    break; 
                  }
                }
                else
                {
                  system("cls");
                  MENU();
                  return; 
                }

              }
            }
            if(strcmp(c,f)==0)
            {
              printf("請輸入新的密碼:\n");
              scanf("%s",c);
            }
          }
          if(q==1||q==2||q==3)
          {
            printf("是否保存?Y/else");
            fflush(stdin);
            y=getchar();
            if(y=='Y')
            {
              fa=fopen("admin.txt","wt");
              fprintf(fa,"%s %s %s %s",a,b,c,d);
              fclose(fa);
              printf("\t\t√保存成功"); 
            }
            else
              printf("\t\t×已放棄修改");
            system("pause");
            system("cls");
            printf("\n\t請選擇所想進行的選項:\n\n");
            printf("\t● ○ ● ○ ● ○ ●\n");
            printf("\t  1.查看個人信息  \n");
            printf("\t○ 2.修改個人信息 ○\n");
            printf("\t  0.返回上一級   \n");//二級 
            printf("\t● ○ ● ○ ● ○ ●\n");
            continue; 
          }
          if(q==0)
          {
            system("cls");
            printf("\n\t請選擇所想進行的選項:\n\n");
            printf("\t● ○ ● ○ ● ○ ●\n");
            printf("\t  1.查看個人信息  \n");
            printf("\t○ 2.修改個人信息 ○\n");
            printf("\t  0.返回上一級   \n");//二級 
            printf("\t● ○ ● ○ ● ○ ●\n");
            continue;
          }
        }
        if(m==0) 
        {
          system("cls");
          MENU1();
          break;
        } 
      } 
    }
    if(n==5)
    {
      system("cls");
      MENU1();
    }
    if(n==0)
    {
      system("cls");
      MENU();
      break;
    }
    if(n!=1&&n!=2&&n!=3&&n!=4&&n!=5&&n!=0)
    {
      printf("\t\t∷");
      Sleep(400);
      printf("∷");
      Sleep(400);
      printf("∷");
      Sleep(400);
      printf("您需要輸入菜單上的數字哦\n"); 
    }  
  }
}
void MENU2_choose()
{
  int n,m,q,i=0;
  char a[20],b[20];
  char y;
  FILE *fp;
  user *u;
  food *p,*s,*r;
  link_food LF,Lf;
  LF=foodread();
  link_user LU;
// user user;
  while(1)
  {
    scanf("%d",&n);
    switch(n)
    {
      case 1:
          system("cls");
          printf("\n\n\t\t\t請選擇需要進行的選項:\n\n");
          printf("\t\t\t--------------------\n");
          printf("\t\t\t  用 戶 相 關\n");
          printf("\t\t\t--------------------\n");
          printf("\t\t\t●  1.修改用戶名\n"); 
          printf("\t\t\t●  2.修改密碼\n"); 
          printf("\t\t\t●  3.修改收貨地址\n");
          printf("\t\t\t●  4.修改電話號\n");
          printf("\t\t\t●  5.查看個人信息\n");
          printf("\t\t\t●  6.充值錢包\n");
          printf("\t\t\t●  0.返回上一級\n");
          LU=userread();
          u=LU->next;
          while(1)
          {
            if(strcmp(yh,u->name)==0)
              break;
            else
              u=u->next;
          }
          while(1)
          {
            scanf("%d",&m);
            if(m==1)
            {
              printf("請輸入新的用戶名:\n");
              scanf("%s",u->name);
            }
            if(m==2)
            {
              printf("您需要輸入舊的密碼:\n");
              scanf("%s",b);
              while(strcmp(u->password,b)!=0)
              {
                printf("密碼錯誤,請重新輸入\n");

                scanf("%s",b);
                i++;
                if(i==2)
                {
                  printf("您已經輸錯三次,請5分鐘后再試");
                  continue; 
                }
              }
              printf("請輸入新的密碼:");
              scanf("%s",u->password); 
            }
            if(m==3)
            {
              printf("請輸入新的收貨地址:");
              scanf("%s",u->delivery); 
            }
            if(m==4)
            { 
              printf("請輸入新的收貨地址");
              scanf("%s",u->number);
            }
            if(m==1||m==2||m==3||m==4)
              userwrite(LU);
            if(m==5)
            {
              printf("您的信息為:\n");
              printf("姓名\t收獲地址\t聯系方式\n"); 
              printf("%s\t%s\t%s\n",u->name,u->delivery,u->number);
            }
            if(m==6)
            {
              u=addmoney(u);
              userwrite(LU); 
            }
            if(m==0)
            {
              system("cls");
              MENU2(); 
              break;
            }

          } 
          break;
      case 2:
        LF=dingdanread();
        Outputfood(LF); 
        break;
      case 3:
        LF=foodread();
        system("cls");
        outputfood(LF);
        p=LF->next; 
        printf("\t●  按1購買,其他數字返回\t");
        scanf("%d",&q);
        if(q==1)
        {
          purchase();
        }
        else
        {
          system("cls");
          MENU2();
          continue;
        }
        break;
      case 4:
        LF=dingdanread();
        p=LF->next;
        i=0;     
        printf("請輸入所想修改的訂單號:");
        scanf("%d",&n);
        while(p)
        {
          if(n==p->type)
          {
            if(strcmp(p->yonghu,yh)==0)
            {
              i=1; 
              system("cls");
              printf("\n訂單信息如下:\n"); 
              printf("\t菜名\t單價\t數量\t總價\t店鋪\t用戶名\t\n");
              printf("\t%s\t%d\t%d\t%d\t%s\t%s\n\n",p->name,p->price,p->amount,p->total,p->shop,p->yonghu); 
              printf("\t\t○  1.修改數量\n");
              printf("\t\t○  2.刪除訂單\n");
              printf("\t\t○  其他數字鍵返回\n"); 
              scanf("%d",&n);
              if(n==1)
              {
                end = time(NULL);
                if((difftime(end,start))<180)
                {
                  printf("還沒有超過三分鐘,請盡快修改哦\n"); 
                  printf("您只能修改菜的數量:");
                  scanf("%d",&m);
                  p->amount=m;
                  p->total=(p->amount)*(p->price);
                  dingdanwrite(LF);
                  printf("\t\t√已成功修改");
                }
                else
                {
                  printf("時間超過三分鐘,已配送\n");
                  system("pause");
                  system("cls");
                  MENU2(); 
                  break;
                }
              }
              if(n==2)
              {
                deletedingdan(LF);
                dingdanwrite(LF); 
              }
              else
              {
                system("pause");
                system("cls");
                MENU2();
                break;
              }
            }
            if(strcmp(p->yonghu,yh)!=0)
            {
              printf("\t\t×  不好意思,該訂單您沒有權限修改\n");
              i=2;
              system("pause"); 
              system("cls");
              MENU2(); 
              break;
            }
          }
          else
            p=p->next;
        }  
        if(i==0)
        {
          printf("\t\t×沒有改訂單\n");
          system("pause");
          system("cls");
          MENU2();
          continue;
        }  
        break; 
      case 5:
        purchase();
        break;
      case 6:
        system("cls");
        printf("\n\n\n\t\t\t---------------\n");
        printf("\t\t\t 訂 單 排 序\n");
        printf("\t\t\t---------------\n"); 
        printf("\t\t\t△ 1.按菜名排序:\n");
        printf("\t\t\t△ 2.按總價排序:\n");
        printf("\t\t\t△ 0.返回\n");
        scanf("%d",&m);
        {
          LF=dingdanread();
          if(m==1)
            dingdan_name_sort(LF);
          if(m==2)
            dingdan_total_sort(LF);
          if(m==0)
          {
            system("cls");
            MENU2();
            continue;
          }
          system("pause");
          system("cls");
          MENU2();
          continue;

        }
        break;
        //dindan_name_sort(LF);
      case 0:
        system("cls");
        MENU();
        return;
        break;
      }
    }
}
void deletefood(link_food Lf)
{
  int i=0;
  food *p,*n;
  p=Lf;
  n=p->next;
  char m[20];
  char a;
  printf("請輸入你所想刪除的菜名:");
  scanf("%s",m);
  while(n)
  {
    if(strcmp(m,n->name)==0)
    {
      if(strcmp(n->shop,dp)==0)
      {
        i++;
        p->next=n->next;
        foodwrite1(Lf);
      }
      else

        printf("不好意思,您沒有權限刪除\n");
      break;
    }
    else
    {
      p=p->next;
      n=n->next;
    }
  }
  if(i==0)
  {
    printf("沒有此菜,無法刪除\n");
    return;
  }
}
void MENU3_choose()
{
  int x,y;
  char a[20];
  link_food LF,Lf;
  LF=foodread();
  food *p;
  while(1)
  {
    printf("請選擇:");
    scanf("%d",&x);
    if(x==1)
    {
      creatf();
      //foodwrite(LF);
    }
    if(x==2)
    {
      int i=0;
      printf("請輸入要修改的菜的名稱:");
      scanf("%s",a);
      //LF=foodread();
      p=LF->next;
      while(p!=NULL)
      {
        if(strcmp(a,p->name)==0)
        {
          i++;
          if(strcmp(dp,p->shop)==0)
          {
            printf("請重新輸入菜的信息:\n");
            printf("\t\t\t△新菜名:");
            scanf("%s",p->name);
            printf("\t\t\t△新菜價:");
            scanf("%d",&p->price);
            foodwrite1(LF); 
          }
          else
            printf("不好意思,您沒有權限修改\n");
          break; 
        }
        p=p->next;
      }
      if(i==0)
        printf("\t\t×  沒有此菜的信息\n"); 
    }
    if(x==3)
    {
      deletefood(LF);
    } 
    if(x==4)
    {
      int sum=0;
      Lf=foodread();
      p=Lf->next;
      system("cls");
      printf("\n\n\t\t您家的食物如下:");
      printf("\n\t\t----------------------------------------\n");
      printf("\t\t菜名\t   菜價\t店鋪\t  菜系\n");
      printf("\t\t----------------------------------------\n"); 
      while(p)
      {
        if(strcmp(p->shop,dp)==0)
        {
          printf("\t\t%-14s%-10d%-12s%s\n",p->name,p->price,p->shop,p->leibie);
          printf("\t\t----------------------------------------\n");
          sum=sum+1;
        }
        p=p->next;
      }
      printf("\t\t合計/個:\t\t\t%d個菜\n",sum);
      printf("\t\t----------------------------------------\n");
      if(sum==0)
        printf("\t\t\t●  怪不得沒訂單,您還沒添加菜品呢\n");
      system("pause");
      system("cls");
      MENU3();
    }
    if(x==5)
    {
      LF=dingdanread();
      scorefind(LF);//查看業績函數
      system("pause");
      system("cls");
      MENU3();
    }    
    if(x==0) 
    {
      system("cls");
      MENU();
      break;
    }  
  } 
}
//登陸
void login()
{
  int n,i=0,j=0;
  char a[10],c[10];
  char b[15],d[15],f[10],e[20];
  FILE *fp;
  char ch;
  system("cls"); 
  MENU();
  printf("請選擇:");
  while(1)
  {
    scanf("%d",&n);
    //管理員登陸 
    if(n==1)
    {
      printf("請輸入用戶名:"); 
      scanf("%s",a);
      printf("請輸入密碼:");
      while((ch=getch())!=13){
      if(ch==8){
        printf("\b \b");
        i--;
        continue;
      }
      b[i++]=ch;
      putchar('*');
      }
      b[i]='\0';
      fp=fopen("admin.txt","rt");
        if(fp==NULL)
          printf("沒有此文件,無法打開");
      fscanf(fp,"%s %s %s %s",f,c,d,e);
      fclose(fp);
      while(strcmp(a,c)!=0||strcmp(b,d)!=0)
      {
        printf("\n賬號或密碼錯誤,請重新輸入:\n");
        printf("請輸入用戶名:");
        scanf("%s",a);
        printf("請輸入密碼:");
        i=0;
        while((ch=getch())!=13){
        if(ch==8){
          printf("\b \b");
          i--;
          continue;
        }
        b[i++]=ch;
        putchar('*');
        }
        b[i]='\0';
        j++;
        if(j==2)
        {
          printf("\n密碼錯誤已達三次,將自動退回主菜單\n");
          system("pause"); 
          system("cls");
          MENU();
          return;
        }
      }
      system("cls");
      //system("color 03");
      welcome();
      printf("\n");
      system("pause");
      system("cls");
      MENU1();
      MENU1_choose(); 
    }
  //用戶登錄 
    if(n==2)
    {
      link_user LU;
      user *p;
      LU=userread();
      p=LU->next;
      printf("請輸入賬號或名稱");
      scanf("%s",yh);
      printf("請輸入密碼:");
      i=0;
      while((ch=getch())!=13){
      if(ch==8){
        printf("\b \b");
        i--;
        continue;
      }
      b[i++]=ch;
      putchar('*');
      }
      b[i]='\0';
      int i=0;
      while(p!=NULL)
      {
        if(strcmp(yh,p->name)==0&&strcmp(b,p->password)==0)
        {
          system("cls");
          //system("color 0a");
          //welcome();
          printf("\n");
          system("pause");
          system("cls");
          i++;
          MENU2();
          MENU2_choose();
          break;
        }
        p=p->next;
      }
      if(i==0)
      { 
        printf("密碼或者賬號錯誤\n");
        system("pause");
        system("cls");
        ME();
        return;
      }
    }
    if(n==3)
    {
      link_shop LS;
      shop *p;
      j=0;
      LS=shopread();
      p=LS->next;
      printf("請輸入店鋪名稱或者賬號:");
      scanf("%s",dp);
      printf("請輸入密碼");
      i=0;
      while((ch=getch())!=13)
      {
        if(ch==8)
        {
          printf("\b \b");
          i--;
          continue;
        }    
        putchar('*');
        b[i++]=ch;
      }
      b[i]='\0';
      while(p!=NULL)
      {
        if(strcmp(dp,p->name)==0&&strcmp(b,p->password)==0)
        {
          system("cls");
          //system("color 0a");
          //welcome();
          j++;
          printf("\n");
          system("pause");
          system("cls");
          MENU3();
          MENU3_choose();
          break;
        }
        else
          p=p->next;
      }
      if(j==0)
      { 
        printf("\t\t\n×  密碼或者賬號錯誤\n");
        system("pause");
        system("cls");
        ME();
        return;
      }
    }
    if(n==0)
    {
      system("cls");
      ME();
      break; 
    }  
  }
}
user * creatu()
{
  char a[30],b[20],c[15],d[20];
  char ca[20],mi1[20],mi2[20];
  link_user LU,lu;
  FILE *fp;
  user *s,*r,*p;
  int x,y,i,h; 
  LU=r=(user *)malloc(sizeof(user));
  LU->next=NULL;
  printf("請輸入姓名:");
  scanf("%s",a);
  lu=userread();
  while(1)
  {
    i=0;
    p=lu->next;
    while(p)
    { 
      if(strcmp(a,p->name)==0)
      {
        i++;
        printf("\t\t×此用戶已經有人注冊過,請重新輸入:");
        scanf("%s",a);
        break;
      }
      else
        p=p->next;
    }
    if(i==0)
      break;
  }
  printf("請輸入收貨地址:");
  scanf("%s",b); 
  printf("請輸入密碼:");
  scanf("%s",c);
  printf("請輸入電話號碼:");
  scanf("%s",d); 
  x=strlen(c);
  while(x<8)
  {
    printf("\t\t●  您的密碼小于8位,安全指數為低\n");
    printf("按1修改,其他鍵放棄修改:");
    scanf("%d",&y);
    if(y==1)
    {
      scanf("%s",c);
      x=strlen(c);  
    }
    else
      break; 
  }
  if(strcmp(b,"0")!=0)
  {
    s=(user *)malloc(sizeof(user));
    s->score=0;
    strcpy(s->name,a);
    strcpy(s->delivery,b);
    strcpy(s->password,c);
    strcpy(s->number,d);
    r->next=s;
    s->next=NULL;
    r=s;
    printf("為了方便充值錢包,請綁定您的銀行卡:");
    scanf("%s",ca);
    h=strlen(ca);
    while(h<15)
    {
      printf("\t\t●  您的銀行卡不足15位,請重新輸入:");
      scanf("%s",ca);
      h=strlen(ca); 
    }
    i=0; 
    printf("請設置您的支付密碼");
    scanf("%s",mi1);
    printf("請確認密碼");
    scanf("%s",mi2);
    if(strcmp(mi1,mi2)!=0)
    {
      printf("\t\t×注冊失敗,兩次密碼不同");
      return 0;
    }
    fp=fopen("yue.txt","at");
    fprintf(fp,"%s %s %s\n",a,ca,mi1);
    fclose(fp);
  }
  else
  {
    printf("\t\t×注冊失敗,請輸入正確的收貨信息:");
    return 0;
  }
  return LU;  
}
void Register()
{
  int y;
  char a;
  FILE *fp;
  shop sq;//申請 
  system("cls");
  printf("\n\n\n\t\t\t\t1.注冊用戶\t\t\t2.申請店鋪\n");
  printf("\t\t\t\t0.返回上一級");
  while(1)
  {
    printf("\t\t▲ 請選擇要進行的選項:"); 
    scanf("%d",&y);
    if(y==1)//用戶注冊 
    {
      link_user LU;
      LU=creatu(); 
      userwrite2(LU);
    }
    if(y==2)
    {
      printf("請輸入店鋪名稱:");
      scanf("%s",sq.name);
      printf("請輸入店鋪電話:");
      scanf("%s",sq.phone);
      printf("請輸入店鋪地址:");
      scanf("%s",sq.address); 
      printf("請輸入店鋪密碼:");
      scanf("%s",sq.password);
      fp=fopen("shenqing.txt","at");
      if(fp==NULL)
      {
        printf("發生錯誤,無法打開文件");
        return; 
      }
      printf("是否保存?Y/else");
      scanf("%*c%c",&a);
      if(a=='Y')
      {  
        fprintf(fp," %s %s %s %s \n",sq.name,sq.phone,sq.address,sq.password);
        fclose(fp);
        printf("\t\t√  申請成功,等待上級審核"); 
      }
      else
      {
        printf("\t\t×  已放棄申請");
        fclose(fp); 
      }
    }
    if(y==0)
    {
      system("cls");
      printf("\t\tWELCOME\n這里是外賣管理系統,請選擇接下來的操作:");
      printf("\n\n\t\t\t\t1.登陸");
      printf("\t\t\t\t2.注冊\n"); 
      break;   
    }
  }
}
void choose()
{
  int x;
  ME();
  while(1)
  {
    scanf("%d",&x);
    if(x==1)
      login();
    if(x==0)
    {
      Exit();
      return;
    }

    if(x==2)
      Register();
  }
}
int main()
{
  choose(); 
}

看完上述內容,你們掌握使用C語言怎么實現一個外賣管理系統的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

庆城县| 宝鸡市| 隆子县| 蓬莱市| 贵德县| 云浮市| 衡东县| 伊金霍洛旗| 托里县| 汶上县| 河曲县| 毕节市| 抚州市| 盐边县| 邯郸县| 阆中市| 澜沧| 吕梁市| 汉寿县| 安龙县| 库车县| 营口市| 乌兰察布市| 招远市| 临泉县| 濉溪县| 陆河县| 临夏市| 岳池县| 郎溪县| 太谷县| 阿克苏市| 从江县| 龙山县| 洮南市| 新泰市| 双城市| 乐山市| 奈曼旗| 金川县| 喀喇|