zoukankan      html  css  js  c++  java
  • 银行ATM机工作流程模拟编程(代码)

    #include<stdio.h>
    #include<stdlib.h>
    #include <conio.h>
    #include <string.h>

    void denglu(struct people *head,struct people *p);
    void jiemian(struct people *head,struct people *p);
    void chaxun(struct people *head,struct people *p);
    void qukuan(struct people *head,struct people *p);
    void cunkuan(struct people *head,struct people *p);
    void xiugai(struct people *head,struct people *p);
    void tuika(struct people *head,struct people *p);
    void xinxi(struct people *head,struct people *p);



    struct people
    {
        char name[10];
        char account[20];
        char password[10];
        float money;
        struct people*next;
    };



    void main()
    {
        int i,z,a,t=0;
        char account[20],password[10],ch;
        struct people *head,*p;
        FILE *fp=fopen("1.txt","r");
        head=NULL;

        if(fp==NULL){printf("系统出错");return 1;}
        for(i=0;i<5;i++)
        {
            p=(struct people*)malloc(sizeof(struct people));
            fscanf(fp,"%s%s%s%f",p->name,p->account,p->password,&(p->money));
            p->next=head;
            head=p;
        }
        fclose(fp);
        printf("***********欢迎使用ATM自动取款机*********** ");
        printf("******************************************* ");
        denglu(head,p);
            
    }


    void denglu(struct people *head,struct people *p)
    {
        int a;
        char account[20];
        int i=0,t=0;
        char password[10],ch;
        printf("请输入卡号:");
        scanf("%s",account);
        //scanf("account:%s password:",account);
        for(a=0;a<5;a++)
        {
            if(strcmp(account,p->account)==0)
            {

                printf("请输入密码:");
                while(1)
                {
                     while((ch=getch())!=' ')
                     {
                        password[i++]=ch;
                        putchar('*');
                     }
                     password[i]='';
                       t++;
                     if(strcmp(password,p->password)==0)
                     {
                         system("cls");
                         printf(" 欢迎使用本系统! ");
                         jiemian(head,p);
                         break;
                     }
                     else
                     {
                         if(t<3)
                         {
                             printf(" 密码错误,请重新输入:");
                             i=0;
                         }
                         else
                         {
                                 printf(" 对不起,你无权使用本系统! 退出系统! ");
                                for(i=0;i<1000000000;i++);
                                system("cls");
                                main();
                         }
                     }
                }
                
               
            }
            else p=p->next;
            
        }
    }

    void jiemian(struct people *head,struct people *p)
    {
        int z;
        printf("1-----------个人信息 ");
        printf("2-----------查询余额 ");
        printf("3---------------取款 ");
        printf("4---------------存款 ");
        printf("5-----------修改密码 ");
        printf("0---------------退卡 ");
        while(1)
        {
            printf(" 请输入序号:");
            scanf("%d",&z);
            switch(z)
            {
            case 1:system("cls");xinxi(head,p);break;
            case 2:system("cls");chaxun(head,p);break;
            case 3:system("cls");qukuan(head,p);break;
            case 4:system("cls");cunkuan(head,p);break;
            case 5:system("cls");xiugai(head,p);break;
            case 0:system("cls");tuika(head,p);break;
            default:printf("操作序号不合法!!!");
            return ;
            }
        }
    }

    void xinxi(struct people *head,struct people *p)
    {
        char gg;
        printf("*********************************************** ");
        printf("            用户名:%s ",p->name);
        printf("              帐号:%s ",p->account);
        printf("*********************************************** ");
        printf("按任意键返回菜单,按N键退卡! ");
        if(gg=getch()=='n')
        {system("cls");tuika(head,p);}
        else
        {system("cls");jiemian(head,p);}
    }

    void chaxun(struct people *head,struct people *p)
    {
        char gg;
        printf("余额:%7.2f元 ",p->money);
        printf("按任意键返回菜单,按N键退卡! ");
        if(gg=getch()=='n')
        {system("cls");tuika(head,p);}
        else
        {system("cls");jiemian(head,p);}
    }


    void qukuan(struct people *head,struct people *p)
    {
        char gg;
        float a;
        struct people *f;
        FILE *fp=fopen("1.txt","w+");
        printf("请输入取款金额:");
        scanf("%f",&a);
        if(a>p->money)
            printf("余额不足!");
        else
        {
            printf("成功取款%7.2f元 ",a);
            p->money=p->money-a;
                f=head;
                while(f!=NULL)
                {
                    fprintf(fp,"%s %s %s %f ",f->name,f->account,f->password,p->money);
                     f=f->next;
                }
                fclose(fp);
        }
        printf("按任意键返回菜单,按N键退卡! ");
        if(gg=getch()=='n')
        {system("cls");tuika(head,p);}
        else
        {system("cls");jiemian(head,p);}

    }

    void cunkuan(struct people *head,struct people *p)
    {
        char gg;
        float a;
        struct people *f;
        FILE *fp=fopen("1.txt","w+");
        printf("请输入存款金额:");
        scanf("%f",&a);
            printf("成功存款%7.2f元 ",a);
            p->money=p->money+a;
                f=head;
                while(f!=NULL)
                {
                    fprintf(fp,"%s %s %s %f ",f->name,f->account,f->password,f->money);
                     f=f->next;
                }
                fclose(fp);
        printf("按任意键返回菜单,按N键退卡! ");
        if(gg=getch()=='n')
        {system("cls");tuika(head,p);}
        else
        {system("cls");jiemian(head,p);}


    }

    void xiugai(struct people *head,struct people *p)
    {
        char gg;
        char a[10],b[10],c[10];
        struct people *f;
        FILE *fp=fopen("1.txt","w+");
        printf("请输入原密码:");
        scanf("%s",a);
        if(strcmp(a,p->password)==0)
        {
            printf("请输入新密码:");
            scanf("%s",b);
            printf("请再次输入新密码:");
            scanf("%s",c);
            if(strcmp(b,c)==0)
            {
                printf("密码修改成功! ");
                strcpy(p->password,b);
                
                f=head;
                while(f!=NULL)
                {
                    fprintf(fp,"%s %s %s %f ",f->name,f->account,f->password,f->money);
                    f=f->next;
                }
                fclose(fp);
            }
            else
                printf("两次输入不同! ");

        }
        else
        {
            printf("原密码输入错误! ");
        }
        
        printf("按任意键返回菜单,按N键退卡! ");
        if(gg=getch()=='n')
            {system("cls");tuika(head,p);}
        else
        {system("cls");jiemian(head,p);}
    }

    void tuika(struct people *head,struct people *p)
    {
        int i ;
        printf("请取回您的磁卡");
        for(i=0;i<1000000000;i++);
        system("cls");
        main();
    }

  • 相关阅读:
    Android Studio教程-创建第一个项目Hello World
    java打jar包的几种方式详解
    低学历者如何逆袭
    strlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l, setlocale(LC_CTYPE, "Japanese_Japan")(MSDN的官方示例)
    select, poll, epoll
    KVM虚拟化知识的一些笔记
    在Windows系统上以C++打印出当前活动用户的环境变量
    日志组件解析
    Angular2案例rebirth开源
    视图
  • 原文地址:https://www.cnblogs.com/mzct123/p/4822895.html
Copyright © 2011-2022 走看看