程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> c說話完成的貨色治理體系實例代碼(增長刪除 查找貨色信息等功效)

c說話完成的貨色治理體系實例代碼(增長刪除 查找貨色信息等功效)

編輯:關於C++

c說話完成的貨色治理體系實例代碼(增長刪除 查找貨色信息等功效)。本站提示廣大學習愛好者:(c說話完成的貨色治理體系實例代碼(增長刪除 查找貨色信息等功效))文章只能為提供參考,不一定能成為您想要的結果。以下是c說話完成的貨色治理體系實例代碼(增長刪除 查找貨色信息等功效)正文



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>        /*屏幕操作函數庫*/

/*主管權限數據格局化*/
#define HEADER1_zg "-----------------------------貨色治理體系(主管)--------------------------------\n"
#define HEADER2_zg "| 編號 |  稱號  | 進價 | 售價 | 產地 | 臨盆日期 |保質期| 庫存 | 銷量 |  支出  |\n"
#define HEADER3_zg "|------|--------|------|------|------|----------|------|------|------|--------|\n"
#define FORMAT_zg  "|%-6s|%-8s|%.2f |%.2f |%6s|%-4d%3d%3d| %4d | %4d | %4d |%.2f |\n"
#define DATA_zg p->data.numbs,p->data.name,p->data.purchase,p->data.sales,p->data.place,p->data.Date.year,p->data.Date.mouth,p->data.Date.day,p->data.days,p->data.stock,p->data.salesnumb,p->data.income
#define END_zg     "-------------------------------------------------------------------------------\n"

/*通俗權限數據格局化*/
#define HEADER1_pt "----------------貨色治理體系(通俗)--------------------\n"
#define HEADER2_pt "| 編號 |  稱號  | 售價 | 產地 | 臨盆日期 |保質期| 銷量 |\n"
#define HEADER3_pt "|------|--------|------|------|----------|------|------|\n"
#define FORMAT_pt  "|%-6s|%-8s| %.2f|%6s|%-4d%3d%3d| %4d | %4d |\n"
#define DATA_pt p->data.numbs,p->data.name,p->data.sales,p->data.place,p->data.Date.year,p->data.Date.mouth,p->data.Date.day,p->data.days,p->data.salesnumb
#define END_pt    "--------------------------------------------------------\n"

int yhflag=0;        /*能否優惠*/
int incomflag=0;   /*能否盤算支出*/
int dateflag=0;   /*能否輸出日期*/
int saveflag=0;   /*能否須要保留*/
char zg[]="zg";
char pt[]="pt";

struct date
{
    int year;
    int mouth;
    int day;
};

/*貨色根本信息*/
struct goods
{
    char numbs[6];    /*編號*/
    char name[10];        /*稱號*/
    float purchase;        /*進價*/
    float sales;    /*售價*/
    char place[10];    /*產地*/
    struct date Date;    /*臨盆日期*/
    int days;  /*保質期*/
    int datecha; /*保質期截止日期差*/
    int stock;    /*庫存量*/
    int  salesnumb;    /*銷量*/
    float income;    /*支出*/
};
typedef struct node
{
    struct goods data;
    struct node *next;
}Node,*Link;

/*格局化輸入主管表頭*/
void printheader_zg()
{
    printf(HEADER1_zg);
    printf(HEADER2_zg);
    printf(HEADER3_zg);
}
/*格局化輸入通俗表頭*/
void printheader_pt()
{
    printf(HEADER1_pt);
    printf(HEADER2_pt);
    printf(HEADER3_pt);
}
/*格局化輸入主管表中數據*/
void printdata_zg(Node *pp)
{
    Node *p;
    p=pp;
    printf(FORMAT_zg,DATA_zg);
}
/*格局化輸入通俗表中數據*/
void printdata_pt(Node *pp)
{
    Node *p;
    p=pp;
    printf(FORMAT_pt,DATA_pt);
}
/*輸入案件毛病信息*/
void wrong()
{
    printf("\n\n\n\n*******毛病:輸出毛病,按隨意率性鍵持續*******\n");
    getchar();
}
/*輸入為查找到貨色的信息*/
void Nofind()
{
    printf("\n*****無此貨色信息!*****\n");
    getchar();
}
/*主管顯示菜單*/
void Disp(Link L,char s[])
{
    Node *p;
    p=L->next;
    if (!p) /*空,則*/
    {
        printf("\n沒有錄入貨色信息\n");
        getchar();
        return ;
    }   
    printf("\n\n");
    if (strcmp(zg,s)==0)
    {
        printheader_zg();
        while (p)
        {
            printdata_zg(p);
            p=p->next;
            printf(HEADER3_zg);
        }
    }
    else
    {
        printheader_pt();
        while (p)
        {
            printdata_pt(p);
            p=p->next;
            printf(HEADER3_pt);
        }
    }

    getchar();
}
/*前往鏈表中相符請求的節點的指針,s[]保留用戶查找內容,NaorNum[]保留按甚麼查找”name,num“*/
Node *Locate(Link L,char s[],char NaorNum[] )
{
    Node *p;
    if (strcmp(NaorNum,"num")==0)
    {
        p=L->next;
        while (p)
        {
            if (strcmp(p->data.numbs,s)==0)
                return p;
            p=p->next;
        }
    }
    else if (strcmp(NaorNum,"name")==0)
    {
        p=L->next;
        while (p)
        {
            if (strcmp(p->data.name,s)==0)
                return p;
            p=p->next;
        }
    }
    return 0;     /*未找到,前往空指針*/
}
/*平潤年斷定*/
int Year_pd(int year)
{
    int flag;
    if ((year%4==0&&year%100!=0)||year%400==0)
    {/*閏年*/
        flag=0;
    }
    else
    {/*閏年*/
        flag=1;
    }
    return flag;
}
/*月份對應的天數*/
int Day_pd(int mouth,int flag)
{
    int day;
    switch(mouth)
    {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:day=31;break;
    case 4:
    case 6:
    case 9:
    case 11:day=30;break;
    case 2:if (flag) day=28;
           else day=29;break;
    }
    return day;
}
/*輸出字符串,並停止驗證,用戶的輸出經由過程*t輸入*/
void S_input(char *t,int lens,char *notice)
{
    char str[255];
    do
    {
        printf(notice);
        scanf("%s",str);
        if(strlen(str)>lens)
            printf("\n跨越了請求長度,從新輸出\n");
    } while (strlen(str)>lens);
    strcpy(t,str);
}

int Num_input(char *notice)
{
    int a;
    do
    {
        printf(notice);
        scanf("%d",&a);
        if(a<0) printf("\n數字必需年夜於零\n");
    } while (a<0);
    return a;
}
/*輸出月份停止驗證*/
int Mou_input(char *notice)
{
    int mouth=0;
    do
    {
        printf(notice);
        scanf("%d",&mouth);
        if (mouth>12||mouth<0)
            printf("\n月份必需在(1~12)之間!\n");
    } while (mouth>12||mouth<0);
    return mouth;
}
/*輸出天數停止驗證*/
int Day_input(char *notice,int year,int mouth)
{
    int day=0;
    int nlimit,flag;
    flag=Year_pd(year);
    do
    {
        printf(notice);
        scanf("%d",&day);
        nlimit=Day_pd(mouth,flag);
        if (day>nlimit||day<0)
            printf("\n日期必需在(1~%d)之間!\n",nlimit);
    } while (day>nlimit||mouth<0);
    return day;
}
/*增長貨色記載*/
void Add_goods(Link L)
{
    Node *p,*r,*s;
    char ch,flag=0,num[10];
    r=L;
    s=L->next;
    system("cls");
    Disp(L,zg);
    while (1)
    {
        while (1) /*輸出編號,包管沒有被應用,若輸出為0,則推出*/
        {
            S_input(num,6,"輸出貨色編號(按‘0'前往菜單界面):");
            flag=0;
            if (strcmp(num,"0")==0) return;
            s=L->next;
            while (s) /*查詢貨色編號能否存在,若存在,要去輸出新編號*/
            {
                if (strcmp(s->data.numbs,num)==0)
                {
                    flag=1;
                    break;
                }
                s=s->next;
            }
            if (flag)
            {
                getchar();
                printf("貨色編號:%s已存在,能否要從新輸出?(y/n)",num);
                scanf("%c",&ch);
                if(ch=='y'||ch=='Y')
                    continue;
                else
                    return;
            }
            else
                break;
        }
        p=(Node *)malloc(sizeof(Node));
        if (!p)
        {
            printf("\n沒有請求到");
            return; /*前往到主界面*/
        }
        strcpy(p->data.numbs,num);
        S_input(p->data.name,8,"稱號:");
        p->data.purchase=Num_input("進價:");
        p->data.sales=Num_input("售價:");
        S_input(p->data.place,6,"產地:");
        p->data.Date.year=Num_input("成產日期:年:");
        p->data.Date.mouth=Mou_input("         月:");
        p->data.Date.day=Day_input("         日:",p->data.Date.year,p->data.Date.mouth);
        p->data.days=Num_input("保質期(天):");
        p->data.stock=Num_input("庫存:");
        p->data.salesnumb=Num_input("銷量:");
        p->data.income=00;
        p->next=r->next;
        r->next=p; /*前插*/
    }
    return ;
}
int select(int a,int b)               /*菜單選擇*/
{
    int n;
    do
    {
        printf("\n\n");
        printf("%15s"," ");
        printf("請輸出一個數(%d~%d): [ ]\b\b",a,b);
        scanf("%d",&n);
    } while (n<a||n>b);
    return n;
}
/*及時盤算現實收益*/
void Sum_Income(Link L)
{
    Node *p;
    p=L->next;
    while (p)
    {
        p->data.income=p->data.salesnumb*(p->data.sales-p->data.purchase);
        p=p->next;
    }
    incomflag=1;
    return ;
}
/*查詢的通用辦法*/
void Sea_by_ways(Link L,Node *p,char s[])
{
    if (p)
    {
        if (strcmp(zg,s)==0)
        {
            printheader_zg();
            printdata_zg(p);
            printf(END_zg);
            printf("按隨意率性鍵前往...");
            getchar();
        }
        else
        {
            printheader_pt();
            printdata_pt(p);
            printf(END_pt);
            printf("按隨意率性鍵前往...");
            getchar();
        }
    }
    else
    {
        Nofind();
        getchar();
    }   
}
/*按編號或貨色稱號查詢*/
void Sea_by_name(Link L,char s[])
{
    Node *p;
    char ss[20];
    system("cls");
    S_input(ss,10,"請輸出要查找的貨色稱號:");
    p=Locate(L,ss,"name");
    Sea_by_ways(L,p,s);
}
void Sea_by_num(Link L,char s[])
{
    Node *p;
    char ss[20];
    system("cls");
    S_input(ss,10,"請輸出要查找的貨色編號:");
    p=Locate(L,ss,"num");
    Sea_by_ways(L,p,s);
}
/*日期絕對於今年的天數*/
int Sum_day(int year,int mouth,int day)
{
    int i,flag,days,sum=0;
    flag=Year_pd(year);
    for (i=1;i<mouth;i++)
    {
        days=Day_pd(i,flag);
        sum+=days;
    }
    return sum+day;
}
/*兩個日期差值*/
void Datecha(Link L)
{
    int year,mouth,day;
    Node *p;
    p=L->next;
    year=Num_input("明天日期:年:");
    mouth=Mou_input("月:");
    day=Day_input("日:",year,mouth);
    dateflag=1;
    if (!p)
    {
        printf("***無貨色信息,不消輸出日期***\n");
        getchar();
        return ;
    }
    else
    {
        while (p)
        {
            p->data.datecha=Sum_day(year,mouth,day)-Sum_day(p->data.Date.year,p->data.Date.mouth,p->data.Date.day);
            p=p->next;
        }
    }
}

void Dz_by_data( Link L)
{
    Node *p,*r;
    Link l;
    int year,mouth,day,count=0;
    p=L->next;
    l=(Node *)malloc(sizeof(Node));
    l->next=NULL;
    system("cls");
    if (!dateflag)
    {
        Datecha(L);
    }
    printf("| 編號 |  稱號  |過時差值|\n");
    while (p)
    {
        printf("|%-6s|%-8s|  %4d  |",p->data.numbs,p->data.name,p->data.datecha);
        if (p->data.days>=p->data.datecha)
        {
            /*優惠的標示優惠*/
            if (p->data.days-p->data.datecha<=10)
            {
                count++;
                p->data.sales=p->data.sales/2;
                printf("已優惠\n");
                /*        Ltol(l,p,p->next);*/
            }
            else
            {
                printf("\n");
            }
        }
        else
        {
            printf("該商品過時,請刪除\n");
        }
        p=p->next;
    }

    if(!count)
    {
        printf("/n***沒有差10天過時的貨色***/n");
        getchar();
        return;
    }
    else
    {
        printf("共有%d中商品打折",count);
        yhflag=1;
        saveflag=1;
        Disp(L,zg);
    }
}
/*刪除*/
void Del_by_ways(Link L,Node *p)
{
    Node *q;
    char ch;
    if (p)
    {
        q=L;
        while(q->next!=p)
            q=q->next;
        printheader_zg();
        printdata_zg(p);
        printf(END_zg);
        getchar();
        printf("請肯定能否要刪除該貨色信息(y/n):");
        scanf("%c",&ch);
        if (ch=='y'||ch=='Y')
        {
            q->next=p->next;
            free(p);
            printf("\n勝利刪除該貨色信息\n");
            saveflag=1;
            getchar();
            return;
        }
        else
        {
            printf("\n沒有刪除該貨色信息\n");
            getchar();
            return;
        }
    }
    else
    {
        Nofind();
        getchar();
    }   
}
/*經由過程稱號刪除*/
void Del_by_name(Link L)
{
    Node *p;
    char s[20];
    system("cls");
    S_input(s,10,"請輸出要查刪除的貨色稱號:");
    p=Locate(L,s,"name");
    Del_by_ways(L,p);
}
/*經由過程編號刪除*/
void Del_by_num(Link L)
{
    Node *p;
    char s[20];
    system("cls");
    S_input(s,10,"請輸出要查刪除的貨色的編號:");
    p=Locate(L,s,"num");
    Del_by_ways(L,p);
}


/*補貨信息*/
void Buhuo(Link L)
{
    Node *p,*q;
    int i=0;
    p=L->next;
    system("cls");
    if (p)
    {
        q=L->next;
        printf("|  編號  |  稱號  |庫存|銷量|殘剩| \n");
        while (q)
        {
            /*統計庫存,銷量,殘剩*/
            printf("|%-8s|%-8s|%-4d|%4d|%4d|\n",q->data.numbs,q->data.name,q->data.stock,q->data.salesnumb,q->data.stock-q->data.salesnumb);
            q=q->next;
        }
        while (p)
        {
            if ((p->data.stock-p->data.salesnumb)<100)
            {
                if (i==0)
                {
                    printf("須要補貨的貨色分離是\n");
                    printf("|  編號  |商品稱號|\n");
                }
                printf("|%-8s|%8s|\n",p->data.numbs,p->data.name);
                i++;
            }
            p=p->next;
        }
        if (i)
        {
            printf("共%d種貨色\n",i);
            getchar();
            return;
        }
        else
        {
            printf("沒有須要彌補的貨色品種\n");
            getchar();
            return;
        }
    }
    else
    {
        printf("\n***沒有貨色信息***\n");
        printf("\n按隨意率性鍵前往...\n");
        getchar();
        return ;
    }
}

void Sort_by_ways(Link L,char s[],int n)
{
    int flag=0,a;
    Node *p,*q,*lq,*fq;   /*fq記下節點先驅,lq記下節點的後驅,q每次冒泡遍歷,p掌握遍歷,qq用來交流地址*/
    p=L->next;
    system("cls");
    while (p)
    {
        fq=L;
        q=fq->next;
        while (lq=q->next)
        {
            if (strcmp(zg,s)==0)
            {
                switch (n)
                {
                case 1:a=strcmp(q->data.name,lq->data.name);break;
                case 2:a=strcmp(q->data.numbs,lq->data.numbs);break;
                case 3:a=(q->data.salesnumb>lq->data.salesnumb);break;
                case 4:if(!incomflag) Sum_Income(L); a=(q->data.income>lq->data.income);break;
                case 5:if (!dateflag) Datecha(L);a=(q->data.datecha>lq->data.datecha);break;
                }
            }
            else
            {
                switch (n)
                {
                case 1:a=strcmp(q->data.name,lq->data.name);break;
                case 2:a=strcmp(q->data.numbs,lq->data.numbs);break;
                case 3:a=(q->data.sales>lq->data.sales);break;
                case 4:a=(q->data.salesnumb>lq->data.salesnumb);break;
                case 5:if (!dateflag) Datecha(L);a=(q->data.datecha>lq->data.datecha);break;
                }
            }

            /*if ((n==1)?(strcmp(q->data.name,lq->data.name)):(strcmp(q->data.numbs,q->data.numbs)))*/
            if(a>0)
            {
                flag=1;
                q->next=lq->next;
                lq->next=q;
                fq->next=lq;
            }
            fq=fq->next;
            q=fq->next;
        }
        if(flag==0) break;
        p=p->next;
    }
    if (strcmp(zg,s)==0)
        Disp(L,zg);
    else
        Disp(L,pt);
}

void Wb_Save(Link L)
{
    FILE *out;
    Node *p;
    int count=0;
    if ((out=fopen("d:\\Goods.txt","w"))==NULL)
    {
        printf("翻開文件掉敗!\n");
        getchar();
        return;
    }
    p=L->next;
    fprintf(out,HEADER1_zg);
    fprintf(out,HEADER2_zg);
    fprintf(out,HEADER3_zg);
    while (p)
    {
        fprintf(out,FORMAT_zg,DATA_zg);
        p=p->next;
        fprintf(out,HEADER3_zg);
        count++;
    }
    if (count>0)
    {
        getchar();
        printf("\n\n\n***文本文件保留完成,共%d條貨色信息保留***\n",count);
        getchar();
        saveflag=0;
    }
    else
    {
        system("cls");
        printf("沒有貨色信息,沒有貨色信息保留\n");
        getchar();
    }
    fclose(out); /*封閉此文件*/
}
void Er_Save(Link L)
{
    FILE *out;
    Node *p;
    int count=0;
    if ((out=fopen("d:\\Goods","wb"))==NULL)
    {
        printf("翻開文件掉敗!\n");
        getchar();
        return;
    }
    p=L->next;

    while (p)
    {
        if (fwrite(p,sizeof(Node),1,out))
        {
            p=p->next;
            count++;
        }
        else
        {
            break;
        }
    }
    if (count>0)
    {
        getchar();
        printf("\n\n\n***二進制文件保留完成,共%d條貨色信息保留***\n",count);
        getchar();
        saveflag=0;
    }
    else
    {
        system("cls");
        printf("沒有貨色信息,沒有貨色信息保留\n");
        getchar();
    }
    fclose(out); /*封閉此文件*/
}
void Menu_sort_zg()
{
    system("cls");
    printf("\n\n\n");
    printf("%30s%s"," ","     排序貨色信息   \n\n");
    printf("%30s%s"," ","********功效*******\n\n");
    printf("%30s%s"," ","*      1.按稱號   *\n\n");
    printf("%30s%s"," ","*      2.按編號   *\n\n");
    printf("%30s%s"," ","*      3.按銷量*\n\n");
    printf("%30s%s"," ","*      4.按利潤*\n\n");
    printf("%30s%s"," ","*      5.按保期  *\n\n");
    printf("%30s%s"," ","*      6.前往     *\n\n");
    printf("%30s%s"," ","*      7.加入     *\n\n");
    printf("%30s%s"," ","********************\n");
}
void Menu_sort_pt()
{
    system("cls");
    printf("\n\n\n");
    printf("%30s%s"," ","     排序貨色信息   \n\n");
    printf("%30s%s"," ","********功效*******\n\n");
    printf("%30s%s"," ","*      1.按稱號   *\n\n");
    printf("%30s%s"," ","*      2.按編號   *\n\n");
    printf("%30s%s"," ","*      3.按售價   *\n\n");
    printf("%30s%s"," ","*      4.按銷量  *\n\n");
    printf("%30s%s"," ","*      5.按保期  *\n\n");
    printf("%30s%s"," ","*      6.前往     *\n\n");
    printf("%30s%s"," ","*      7.加入     *\n\n");
    printf("%30s%s"," ","********************\n");
}
void Menu_del()
{
    system("cls");
    printf("\n\n\n");
    printf("%30s%s"," ","     刪除貨色信息   \n\n");
    printf("%30s%s"," ","********功效*******\n\n");
    printf("%30s%s"," ","*      1.按稱號   *\n\n");
    printf("%30s%s"," ","*      2.按編號   *\n\n");
    printf("%30s%s"," ","*      3.前往     *\n\n");
    printf("%30s%s"," ","*      4.加入     *\n\n");
    printf("%30s%s"," ","********************\n");
}
void Menu_Sea()
{
    system("cls");
    printf("\n\n\n");
    printf("%30s%s"," ","     查詢貨色信息   \n\n");
    printf("%30s%s"," ","********功效*******\n\n");
    printf("%30s%s"," ","*      1.按稱號   *\n\n");
    printf("%30s%s"," ","*      2.按編號   *\n\n");
    printf("%30s%s"," ","*      3.前往     *\n\n");
    printf("%30s%s"," ","*      4.加入     *\n\n");
    printf("%30s%s"," ","********************\n");
}
void Menu_Qx()                   /*權限菜單*/
{
    system("cls");
    printf("\n\n\n");
    printf("%25s%s"," ","        迎接進入             \n");
    printf("%25s%s"," ","     貨色治理體統   \n\n\n");
    printf("%25s%s"," ","**********功效*********\n\n");
    printf("%25s%s"," ","*        1.主管       *\n\n");
    printf("%25s%s"," ","*        2.通俗用戶   *\n\n");
    printf("%25s%s"," ","*        3.加入       *\n\n");
    printf("%25s%s"," ","***********************\n");
}
void Menu_zg()                       /*主管菜單*/
{
    system("cls");
    printf("\n\n\n");
    printf("%15s%s"," ","               貨色治理體統                               \n\n\n");
    printf("%15s%s"," ","*****************主管功效******************\n\n");
    printf("%15s%s"," ","*              1.錄入貨色信息             *\n");
    printf("%15s%s"," ","*              2.刪除貨色信息             *\n");
    printf("%15s%s"," ","*              3.查找貨色信息             *\n");
    printf("%15s%s"," ","*              4.顯示貨色信息             *\n");
    printf("%15s%s"," ","*              5.差10天過物信息(促銷)    *\n");
    printf("%15s%s"," ","*              6.統計貨色數目(補貨)     *\n");
    printf("%15s%s"," ","*              7.及時收益                 *\n");
    printf("%15s%s"," ","*              9.排序日期差               *\n");
    printf("%15s%s"," ","*              10.保留文件                *\n");
    printf("%15s%s"," ","*              11.前往                    *\n");
    printf("%15s%s"," ","*              12.加入                    *\n");
    printf("%15s%s"," ","*******************************************\n");
}
void Menu_pt()                        /*通俗菜單*/
{
    printf("%15s%s"," ","               貨色治理體統                               \n\n\n");
    printf("%15s%s"," ","*****************通俗用戶功效***************\n\n");
    printf("%15s%s"," ","*              1.查找貨色信息                   *\n");
    printf("%15s%s"," ","*              2.顯示貨色信息                   *\n");
    printf("%15s%s"," ","*              3.排序貨色銷量                   *\n");
    printf("%15s%s"," ","*              4.前往                           *\n");
    printf("%15s%s"," ","*              5.加入                          *\n");
    printf("%15s%s"," ","*************************************************\n");
}
void Isaveflag(Link L)
{
    char ch;
    if (saveflag)
    {
        printf("您曾經修正數據了,能否要保留加入(y/n):");
        getchar();
        scanf("%c",&ch);
        if (ch=='y'||ch=='Y')
        {
            Wb_Save(L);
            Er_Save(L);
            exit(0);
        }
        else
            exit(0);
    }
    else
        exit(0);
}
int IsPassword()                      /*暗碼能否經由過程*/
{
    char password[7];
    char mypassword[]="123456";
    static int n=3;
    int i;
    system("cls");
    for (;n>0;n--)
    {
        switch(n)
        {
        case 1:
        case 2: printf("暗碼毛病,您還有%d次機遇,請再輸出:",n);break;
        case 3: printf("請輸出6位進入主管功效的暗碼:");getchar();break;
        }
        for ( i=0;i<6;i++)
        {
            password[i]=getch();
            printf("*");
        }
        getchar();
        password[6]='\0';
        if (strcmp(mypassword,password)==0)
        {
            printf("***暗碼准確***");
            getchar();
            return 1;
        }
    }
    printf("祝賀你,三次都輸錯了,沒法再輸出暗碼,按隨意率性鍵前往...");
    getchar();
    return 0;
}

void Sort_goods(Link L,char s[])
{
    if (!L->next)
    {
        system("cls");
        printf("\n沒有貨色信息,沒法應用排序功效\n");
        getchar();
        return;
    }
    else
    {
        if (strcmp(zg,s)==0)
        {
            system("cls");
            for (;;)
            {
                Menu_sort_zg();
                switch(select(1,7))
                {
                case 1:Sort_by_ways(L,zg,1);break;    /*稱號*/
                case 2:Sort_by_ways(L,zg,2);break;     /*編號*/
                case 3:Sort_by_ways(L,zg,3);break;     /*銷量*/
                case 4:Sort_by_ways(L,zg,4);break;     /*利潤*/
                case 5:Sort_by_ways(L,zg,5);break;     /*保期*/
                case 6:return;break;
                case 7:Isaveflag(L);break;
                }
                getchar();
            }
        }
        else
        {
            system("cls");
            for (;;)
            {
                Menu_sort_pt();
                switch(select(1,7))
                {
                case 1:Sort_by_ways(L,pt,1);break;        /*稱號*/
                case 2:Sort_by_ways(L,pt,2);break;        /*編號*/
                case 3:Sort_by_ways(L,pt,3);break;        /*售價*/
                case 4:Sort_by_ways(L,pt,4);break;        /*銷量*/
                case 5:Sort_by_ways(L,pt,5);break;        /*銷量*/
                case 6:return;break;
                case 7:Isaveflag(L);break;
                }
                getchar();
            }
        }
    }
}
void Sea_goods(Link L,char s[])
{
    if (!L->next)
    {
        system("cls");
        printf("\n***沒有貨色記載,不克不及進入查詢功效***\n");
        return ;
    }
    else
    {
        system("cls");
        for (;;)
        {
            Menu_Sea();
            switch(select(1,4))
            {
            case 1:Sea_by_name(L,s);break;
            case 2:Sea_by_num(L,s);break;
            case 3:return;break;
            case 4:Isaveflag(L);break;
            }
            getchar();
        }
    }
}
void Del_goods(Link L)
{
    if (!L->next)
    {
        system("cls");
        printf("\n***沒有貨色記載,不克不及應用刪除功效***\n");
        return ;
    }
    else
    {
        system("cls");
        for (;;)
        {
            Menu_del();
            switch (select(1,4))
            {
            case 1:Del_by_name(L);break;
            case 2:Del_by_num(L);break;
            case 3:return;break;
            case 4:Isaveflag(L);break;
            }
            getchar();
        }
    }
}
void main_zg(Link L)                        /*主管功效*/
{
    system("cls");
    for (;;)
    {
        Menu_zg();
        switch (select(1,12))
        {
        case 1:Add_goods(L);saveflag=1;break;                 /*增長貨色信息*/
        case 2:Del_goods(L);break;                 /*刪除先生信息*/
        case 3:Sea_goods(L,zg);break;         /*按編號名字查詢*/
        case 4:system("cls");Disp(L,zg);break; 
        case 5:Dz_by_data(L);break;
        case 6:Buhuo(L);break;
        case 7:Disp(L,zg);Sum_Income(L);Disp(L,zg);break;
        case 9:Sort_goods(L,zg);break;
        case 10:Wb_Save(L);Er_Save(L);break;
        case 11:return;break;
        case 12:Isaveflag(L);break;
        }
        getchar();
    }
}
void main_pt(Link L)                        /*通俗功效*/
{
    system("cls");
    for (;;)
    {
        Menu_pt();
        switch (select(1,5))
        {
        case 1:Sea_goods(L,pt);break;         /*按編號名字查詢*/
        case 2:system("cls");Disp(L,pt);break; 
        case 3:Sort_goods(L,pt);break;
        case 4:return;break;
        case 5:Isaveflag(L);break;
        }
        getchar();
        system("cls");
    }
}
int main()
{
    Link L;
    FILE *in;
    Node *p,*r;
    int count=0;
    L=(Node *)malloc(sizeof(Node));
    L->next=NULL;
    r=L;
    if ((in=fopen("d:\\Goods","ab+"))==NULL) /*以追加方法翻開二進制文件*/
    {
        printf("\n***翻開文件掉敗***\n");
        exit(0);
    }
    while (!feof(in))
    {
        p=(Node *)malloc(sizeof(Node));
        if (fread(p,sizeof(Node),1,in))
        {
            p->next=r->next;
            r->next=p;
            count++;
        }
    }
    fclose(in);
    for (;;)
    {
        Menu_Qx();
        switch (select(1,3))
        {
        case 1:if(IsPassword())
               {
                   main_zg(L);
               }
               break;
        case 2:main_pt(L);break;
        case 3:Isaveflag(L);break;
        }
        getchar();
    }
    return 0;
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved