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

溫馨提示×

溫馨提示×

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

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

C語言如何實現自動存取款機模擬系統

發布時間:2022-05-30 10:31:33 來源:億速云 閱讀:138 作者:iii 欄目:開發技術

這篇文章主要講解了“C語言如何實現自動存取款機模擬系統”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“C語言如何實現自動存取款機模擬系統”吧!

C語言如何實現自動存取款機模擬系統

C語言如何實現自動存取款機模擬系統

C語言如何實現自動存取款機模擬系統

/*
    c語言課程設計項目名稱:自動存取款機模擬系統
    作者:施瑞文 
    專業:軟件工程(商業智能) 
    時間:2018.2.27 
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
#include<time.h> 
#define N sizeof(struct Account)
#define M sizeof(struct Money)
struct Account       //賬戶信息 
{
    char name[10];       //賬號昵稱 
    char password[18];       //密碼 
    struct Account *next;   //指針域 
};
typedef struct Account Acc;
typedef Acc *Accp;
 
struct Money     //錢 
{
    float money;
    char time[10];//時間
    char date[10];//日期 
    struct Money *next;
};
typedef struct Money mon;
typedef mon *monp;
 
//函數聲明區 
void HideCursor();          //隱藏光標
void toxy(int x, int y);    //將光標移動到X,Y坐標處
void color(short x);     //設置顏色
void menu();               //菜單 
Accp ff();                 //將文件中的內容讀出  
void signin();               //登陸或注冊 
void login();                 // 注冊賬號 
void logon();                  // 賬號登陸   
void amend_password();      //修改密碼
void add_money();     //存款 
void find_money();   //查詢 
void get_money();    //取款
void transfer_money();   //轉賬
void save_account(Accp p);  //將p所指向的內容存入文件中
void save_money(monp p);     //將p所指向的內容存入文件中 
float Sum();          //求余額 
void over();                  //退出系統  
void list();   //賬單明細 
monp ss();
 
 
char _name[20],_password[18];       //全局變量記住當前登陸賬戶 
 
void color(short x)
{
    if(x>=0&&x<=15)
    {
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
    }
    else
    {
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
    }
} 
 
void HideCursor()     //隱藏光標
{
 CONSOLE_CURSOR_INFO cursor_info = {1, 0}; 
 SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
 
void toxy(int x, int y)      //將光標移動到X,Y坐標處
{
COORD pos = { x , y };
HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out, pos); 
}
 
Accp ff()               //將存賬號的文件里的內容輸出到鏈表中
{
    FILE *fp;       //文件指針 
    int n=0;
    Accp head=NULL;
    Accp p2,p;
    fp=fopen("account","a+");     //以只讀的方式打開文件 
    if(fp==NULL)
    {
        printf("cannot open file\n");
    }
    else
    {
        while(!feof(fp))        //判斷文件位置標志是否移動到文件末尾 
        {
           n++;
               p=(Accp)malloc(N); //向內存申請一段空間 
           fread(p,N,1,fp);     //將fp所指向的文件中的內容賦給p 
           if(n==1)
           {
              head=p;
              p2=p;
            }
            else             //創建鏈表 
            {
                p2->next=p;
                p2=p;
            }
        }
        p2->next=NULL;
    }
    fclose(fp);    //關閉文件 
    return head;   //返回頭指針 
}
 
void menu()     //菜單 
{
    system("cls");    //清屏  
    do{
        color(14);     //看著舒服的顏色
        char t;
        toxy(50,5);
        printf(" 自動存取款機模擬系統");
        toxy(50,6);
        printf("當前賬戶為:%s",_name);
        toxy(48,8);
        printf("|     1.取款          |");
        toxy(48,10);
        printf("|     2.轉賬          |");
        toxy(48,12);
        printf("|     3.余額          |");
        toxy(48,14);
        printf("|     4.明細          |");
        toxy(48,16);
        printf("|     5.存款          |");
        toxy(48,18);
        printf("|     6.修改密碼      |"); 
        toxy(48,20);
        printf("|     7.退出系統      |");
        t=getch();                    //利用不回顯函數,輸入t,可以不用手動按回車鍵 
        switch(t)
        {
            case '1':get_money();break; 
            case '2':transfer_money();break;
            case '3':find_money();break;
            case '4':list();break; 
            case '5':add_money();break;
            case '6':amend_password();break;
            case '7':over();break;
            default :;break;
        }
    }while(1);       //永遠為真 
}
 
void signin()       //登陸或注冊 
{
    system("cls");
    color(12); 
    HideCursor();    //隱藏光標
    char t;
    toxy(50,5);
    printf("自動存取款機模擬系統");
    toxy(44,8);
    printf("----------------------------");
    toxy(45,10);
    printf("請輸入(1:登陸;2:注冊.)");
    toxy(44,12);
    printf("----------------------------");
    while(1)
    {
        t=getch();
        switch(t)
        {
            case '1':logon();break;
            case '2':login();break;
            default :break;
        }
    }
}
 
void logon()      // 賬號登陸 
{ 
    system("cls");   //清屏 
    color(10);     //設置顏色 
    Accp p,head;    
    head=ff();    //調用函數 ,返回值為頭結點的指針 
    do{
        p=head;
        char t,c,k;
        int i=0;;
        toxy(50,5);
        printf("自動存取款機模擬系統");
        toxy(45,6);
        printf("***************************");
        toxy(45,8);
        printf("     登陸狀態       ");
        toxy(45,10);
        printf("*  請輸入您的賬號:");
        gets(_name);
        toxy(45,12);
        printf("*  請輸入您的密碼:");
        for(;;)              //此處為輸入密碼不回顯操作 
        {
            k=getch();       //輸入k 
            if(k=='\r')      //如果輸入k為回車,則跳出循環 
            {
                break;
            }
            else if(k=='\b')  //如果輸入k為刪除鍵 
            {
                if(i>0)       //如若密碼還沒完全刪除 
                {
                    printf("\b");
                    printf(" ");
                    printf("\b");
                    i--;
                }
            }
            else              //如果輸入的k既不是刪除鍵,也不是回車鍵 
            {
                _password[i]=k;   //把k的值賦給_password[i]; 
                printf("*");      //輸出*號,保護用戶隱私 
                i++;              //密碼位數加1 
            }
        }
        _password[i]='\0';
        while(p!=NULL&&strcmp(p->name,_name)!=0)   //遍歷鏈表,尋找當前輸入的賬戶的賬號 
        {
            p=p->next;
        }
        if(p!=NULL)   //如果p不為空 
        {
            if(strcmp(p->password,_password)==0)     //如果輸入的密碼正確 
            {
                toxy(48,16);
                printf("正在登陸....");
                Sleep(500);      //暫停0.5秒
                system("cls");
                color(10);
                toxy(48,10);
                printf("登陸成功!");
                break;    //跳出循環
            }
            else      //如果輸入的密碼錯誤
            { 
                toxy(48,16);
                printf("正在登陸....");
                Sleep(500);
                system("cls");
                color(10);
                toxy(46,8);
                printf("-------------------------");
                toxy(46,9);
                printf("|                       |");
                toxy(46,10);
                printf("| 密碼錯誤!是否繼續?  |");
                toxy(46,12);
                printf("| 1.是             2.否 |");
                toxy(46,13);
                printf("|                       |");
                toxy(46,14);
                printf("-------------------------");
                while(1)
                {
                    t=getch();  //輸入t    
                    if(t=='1')          
                    {
                        system("cls");  //清屏 
                        color(10); 
                        break;
                    }
                    else if(t=='2')     //如果輸入t為n,進入開始界面 
                    {
                        signin();break;
                    }
                }
            } 
       }
       else              //如果p為空,即輸入的賬號不正確 
       {
               toxy(48,16);
               printf("正在登陸....");
               Sleep(500);
               system("cls");
               color(10);
               toxy(46,8);
               printf("-------------------------");
               toxy(46,9);
               printf("|                       |");
               toxy(46,10);
            printf("|  賬號錯誤!是否繼續? |");
            toxy(46,11);
            printf("|                       |");
            toxy(46,12);
            printf("|  1.是            2.否 |"); 
            toxy(46,13);
            printf("|                       |");
            toxy(46,14);
            printf("-------------------------");
            while(1)      //死循環防止其他按鍵干擾 
            {
                c=getch();
                if(c=='1')
                {  
                    system("cls");
                    color(10);
                    break;
                }
                else if(c=='2')
                {
                    signin();break;
                }
            }
       }
    }while(1);      //永遠為真 
   Sleep(500);      //暫停0.5秒 
   menu();         //賬號密碼均正確,進入主菜單 
}
 
void login()        //注冊賬號 
{
    
    system("cls");
    color(10); 
    Accp p1;
    p1=(Accp)malloc(N);     //向內存申請一段空間 
    do{
        color(10);
        char name[20],password[18],againpassword[18],c,k;
        int i=0;; 
        toxy(50,5);
        printf("自動存取款機模擬系統");
        toxy(45,6);
        printf("**************************");
        toxy(45,8);
        printf("   正在注冊");
        toxy(45,10);
        printf("*  請輸入賬號:");
        gets(name);
        toxy(45,12);
        printf("*  請輸入密碼:");
        for(;;)              //此處為輸入密碼不回顯操作 
        {
            k=getch();       //輸入k 
            if(k=='\r')      //如果輸入k為回車,則跳出循環 
            {
                break;
            }
            else if(k=='\b')  //如果輸入k為刪除鍵 
            {
                if(i>0)       //如若密碼還沒完全刪除 
                {
                    printf("\b");
                    printf(" ");
                    printf("\b");
                    i--;
                }
            }
            else              //如果輸入的k既不是刪除鍵,也不是回車鍵 
            {
                password[i]=k;   //把k的值賦給_password[i]; 
                printf("*");      //輸出*號,保護用戶隱私 
                i++;              //密碼位數加1 
            }
        }
        password[i]='\0';
        i=0;
        toxy(45,14);
        printf("*  請確認您的密碼:");
        for(;;)              //此處為輸入密碼不回顯操作 
        {
            k=getch();       //輸入k 
            if(k=='\r')      //如果輸入k為回車,則跳出循環 
            {
                break;
            }
            else if(k=='\b')  //如果輸入k為刪除鍵 
            {
                if(i>0)       //如若密碼還沒完全刪除 
                {
                    printf("\b");
                    printf(" ");
                    printf("\b");
                    i--;
                }
            }
            else              //如果輸入的k既不是刪除鍵,也不是回車鍵 
            {
                againpassword[i]=k;   //把k的值賦給_password[i]; 
                printf("*");      //輸出*號,保護用戶隱私 
                i++;              //密碼位數加1 
            }
        }
        againpassword[i]='\0';
        if(strcmp(password,againpassword)==0)        //如果輸入的兩次密碼均正確 
        {
            strcpy(p1->name,name);
            strcpy(p1->password,password);
            toxy(48,16);
            printf("正在注冊....");
            Sleep(500);
            system("cls");
            color(12);
            toxy(48,10);
            printf("注冊成功!");
            Sleep(500);         //暫停0.5秒 
            break;              //跳出循環 
        }
        else    //如果輸入的兩次密碼不同 
        {
            toxy(48,16);
            printf("正在注冊....");
            Sleep(500);
            system("cls");
            color(12);
            toxy(46,8);
            printf("-----------------------------");
            toxy(46,9);
            printf("|                           |");
            toxy(46,10);
            printf("|  注冊失敗!是否繼續注冊? |");
            toxy(46,11);
            printf("|                           |");
            toxy(46,12);
            printf("|  1.是               2.否  |"); 
            toxy(46,13);
            printf("|                           |");
            toxy(46,14);
            printf("-----------------------------");
            while(1)
            {
                c=getch();
                if(c=='1')
                {
                    system("cls");
                    color(12);
                    break;
                }
                else if(c=='2')
                {
                    signin();
                    break;
                }
            }
        }
    }while(1);    //永遠為真 
    save_account(p1);     //調用函數,將p1所指向的內容存儲到文件中 
    toxy(48,12);
    printf("正在自動為您登陸....");
    Sleep(500);
    menu();    //注冊成功后進入主菜單 
}
 
 
/*修改密碼
方法比較笨,這里是先將儲存在文件中的賬戶信息
輸出在一個鏈表中,遍歷鏈表,尋找當前登陸的賬戶賬號,修改該節點的p->password,
再將修改后的鏈表存到文件中,需要注意的是修改之后再存到文件中需要將該文件中的內容
清空*/ 
void amend_password()        //修改密碼 
{ 
    system("cls");         //清屏 
    color(14);    //看著舒服的顏色 
    HideCursor();  
    Accp p,head;       //隱藏光標,看著更舒服 
    head=ff();
    FILE *fp;
    do
    {
        color(14);
        HideCursor();       //隱藏光標,看著舒服 
        p=head;
        char password[18],newpassword[18],t,k;
        int i=0;
        toxy(50,5);          //將光標移動到坐標為(50,5)的位置 
        printf("自動存取款機模擬系統");
        toxy(50,8);
        printf("修改密碼");
        toxy(48,10);
        printf("請輸入舊密碼:");
        for(;;)              //此處為輸入密碼不回顯操作 
        {
            k=getch();       //輸入k 
            if(k=='\r')      //如果輸入k為回車,則跳出循環 
            {
                break;
            }
            else if(k=='\b')  //如果輸入k為刪除鍵 
            {
                if(i>0)       //如若密碼還沒完全刪除 
                {
                    printf("\b");
                    printf(" ");
                    printf("\b");
                    i--;
                }
            }
            else              //如果輸入的k既不是刪除鍵,也不是回車鍵 
            {
                password[i]=k;   //把k的值賦給_password[i]; 
                printf("*");      //輸出*號,保護用戶隱私 
                i++;              //密碼位數加1 
            }
        }
        password[i]='\0';
        i=0;
        toxy(48,12);
        printf("請輸入新密碼:");
        for(;;)              //此處為輸入密碼不回顯操作 
        {
            k=getch();       //輸入k 
            if(k=='\r')      //如果輸入k為回車,則跳出循環 
            {
                break;
            }
            else if(k=='\b')  //如果輸入k為刪除鍵 
            {
                if(i>0)       //如若密碼還沒完全刪除 
                {
                    printf("\b");
                    printf(" ");
                    printf("\b");
                    i--;
                }
            }
            else              //如果輸入的k既不是刪除鍵,也不是回車鍵 
            {
                newpassword[i]=k;   //把k的值賦給_password[i]; 
                printf("*");      //輸出*號,保護用戶隱私 
                i++;              //密碼位數加1 
            }
        }
        newpassword[i]='\0';
        while(p!=NULL&&strcmp(p->name,_name)!=0)//遍歷鏈表,尋找當前登陸賬戶的賬號 
        {
            p=p->next;
        }
        if(p!=NULL)                   //如果p不為空 
        {
            if(strcmp(p->password,password)==0)          //如果舊密碼輸入正確 
            {
                strcpy(p->password,newpassword);         //將舊密碼改為新密碼 
                break;                                   //跳出循環 
            }
            else                                         //如果舊密碼輸入錯誤 
            {
                system("cls");
                color(12);
                toxy(46,8);
                printf("--------------------------");
                toxy(46,9);
                printf("|                        |");
                toxy(46,10);
                printf("|  密碼錯誤!是否繼續?  |");
                toxy(46,11);
                printf("|                        |");
                toxy(46,12);
                printf("|  1.是           2.否   |");
                toxy(46,13);
                printf("|                        |");
                toxy(46,14);
                printf("--------------------------");
                while(1)
                {
                    t=getch();                              //輸入t 
                    if(t=='1')
                    {
                        system("cls");
                        color(12);
                        break;
                    }
                    else if(t=='2')
                      menu();
                }
            }
        }
    }while(1);                                //永遠為真 
    p=head->next;                           //使p指向第二個結點 
    fp=fopen("account","w");                  //先清空原文件內容再將修改后的信息寫入文件 
    if(fp==NULL)
    {
        printf("cannot open file\n");
    }
    if(fwrite(head,N,1,fp)!=1)                 //將head所指向的數據寫入fp所指向的文件 
    {
        printf("file write error\n");
    }
    fclose(fp);                         //關閉文件 
    fp=fopen("account","a");          // 打開account文件,方式為追加 
    while(p!=NULL)                    //p不為空就執行循環體 
    {
        if(fwrite(p,N,1,fp)!=1)            //將p所指向的1個大小為N的數據結構寫入fp所指向的文件 
        {
        printf("file write error\n");
        }
        p=p->next;                     //使p指向下一個結點 
    }
    fclose(fp);              //關閉文件 
    toxy(48,14);
    printf("修改成功!正在跳轉...");
    Sleep(500);       //暫停0.5秒 
}
 
 
void save_account(Accp p1)     //將p1所指向的內容存儲到文件中 
{
    FILE *fp;       //文件指針 
    fp=fopen("account","a");    //以追加的方式打開文件 
    if(fp==NULL)
    {
        printf("cannot open file\n");
    }
    if(fwrite(p1,N,1,fp)!=1)    //將p1所指向的1個大小為N的數據結構寫入fp所指向的文件中 
    {
        printf("file write error\n");
    }
    fclose(fp);        //關閉文件 
}
 
void add_money()       //存款 
{
    do
    {
        system("cls");   //清屏 
        color(11);
        monp p;
        char t; 
        char time[10],date[10];
        p=(monp)malloc(M);   //向內存申請一段空間 
        toxy(48,8);
        printf("請輸入您需要存入的金額:");
        scanf("%f",&p->money);
        getchar(); //吸收回車鍵 
        _tzset(); 
        _strtime(time);      
        strcpy(p->time,time);
        _strdate(date);
        strcpy(p->date,date);   
        toxy(48,10);
        printf("正在操作,請稍后....");
        Sleep(500);
        save_money(p);
        system("cls");
        toxy(46,8);
        printf("-------------------------");
        toxy(46,9);
        printf("|                       |");
        toxy(46,10);
        printf("| 存入成功!是否繼續?  |");
        toxy(46,12);
        printf("| 1.是             2.否 |");
        toxy(46,13);
        printf("|                       |");
        toxy(46,14);
        printf("-------------------------");
        while(1)
        {
            t=getch();
            if(t=='1')
            {
                break;
            }
            else if(t=='2')
            {
                menu();
            }
        }
    }while(1);
}
 
void find_money()     //查詢余額 
{
    system("cls");
    color(13);
    float sum=0;
    sum=Sum();
    toxy(46,12);
    printf("余額為:%f",sum);
    toxy(46,16);
    printf("按任意鍵回到主菜單");
    getch();
    menu(); 
}
 
void get_money()      //取款 
{
    do
    {
        system("cls");
        color(11);
        monp p;
        float money,sum;
        char t;
        char time[10],date[10];
        toxy(46,12);
        printf("請輸入您要取的金額:");
        scanf("%f",&money); 
        getchar();//吸收回車鍵 
        sum=Sum();
        if(money>sum)   //如果要取的金額大于余額 
        {
            toxy(46,14);
            printf("余額不足,請重新輸入!");
            Sleep(500);
            continue;    //結束本次循環 
        }
        p=(monp)malloc(M);    //向內存申請一段空間 
        _tzset(); 
        _strtime(time);      
        strcpy(p->time,time);
        _strdate(date);
        strcpy(p->date,date);  
        p->money=-money;
        save_money(p);      
        toxy(46,14);
        printf("正在操作,請稍后....");
        Sleep(500);
        system("cls");
        toxy(46,8);
        printf("-------------------------");
        toxy(46,9);
        printf("|                       |");
        toxy(46,10);
        printf("| 取款成功!是否繼續?  |");
        toxy(46,12);
        printf("| 1.是             2.否 |");
        toxy(46,13);
        printf("|                       |");
        toxy(46,14);
        printf("-------------------------");
        while(1)
        {
            t=getch();
            if(t=='1')
            {
                break;
            }
            else if(t=='2')
            {
                menu();break;
            }
        }
    }while(1);
    
}
 
void list()  //明細 
{
    system("cls");
    color(10);
    monp head,p;
    int i=10;
    head=ss();
    p=head;
    toxy(50,5);
    printf(" 自動存取款機模擬系統");
    toxy(54,6);
    printf("賬單明細");
    toxy(30,7);
    printf("-------------------------------------------------------------");
    toxy(31,8);
    printf("金       額              時       間             日      期");
    toxy(30,9);
    printf("-------------------------------------------------------------");
    while(p!=NULL)
    {
        toxy(30,i);
        if(p->money>=0)
        {
            printf("+%f                %-24s%s",p->money,p->time,p->date);
        }
        else
        {
            printf("%f                %-24s%s",p->money,p->time,p->date);
        }
        p=p->next;
        i++;
    }
    toxy(50,i);
    printf("請按任意鍵返回主菜單");
    getch();
    menu();
}
 
void transfer_money()     //轉賬 
{
    do
    {
        system("cls");
        color(10);
        FILE *fp1;
        monp p,head,p1;
        float money,sum=0;
        char name[20],t;
        char time[10],date[10];
        toxy(46,12);
        printf("請輸入您要轉入的賬號:");
        gets(name);
        toxy(46,14);
        printf("請輸入您要轉出的金額:");
        scanf("%f",&money);
        getchar();   //吸收回車鍵 
        sum=Sum();
        if(money>sum)   //如果要轉出的金額大于余額 
        {
            toxy(46,16);
            printf("余額不足!");
            Sleep(500);
            continue;   //結束本次循環 
         } 
        fp1=fopen(name,"rb");    //以只讀的方式打開名字為name的二進制文件  
        if(fp1==NULL)    //如果文件不存在 
        {
            toxy(46,16);
            printf("賬戶不存在!");
            fclose(fp1);
            Sleep(500);
            continue;
        }
        fp1=fopen(name,"ab");    //以追加的方式打開名字為name的二進制文件  
        p=(monp)malloc(M);  //向內存申請一段空間 
        p->money=-money;
        _tzset(); 
        _strtime(time);      
        strcpy(p->time,time);
        _strdate(date);
        strcpy(p->date,date);  
        save_money(p);
        p1=(monp)malloc(M);
        p1->money=money;
        strcpy(p1->time,time);
        strcpy(p1->date,date);
        if(fwrite(p1,M,1,fp1)!=1)    //將p1所指向的一個大小為M的節點 存入fp1所指向的文件中 
        {
            printf("轉賬失敗,請重試!");
            continue;
        }
        fclose(fp1);
        toxy(46,18);
        printf("正在操作,請稍后....");
        Sleep(500);
        system("cls");
        toxy(46,8);
        printf("-------------------------");
        toxy(46,9);
        printf("|                       |");
        toxy(46,10);
        printf("| 轉賬成功!是否繼續?  |");
        toxy(46,12);
        printf("| 1.是             2.否 |");
        toxy(46,13);
        printf("|                       |");
        toxy(46,14);
        printf("-------------------------");
        while(1)
        {
            t=getch();
            if(t=='1')
            {
                break;
            }
            else if(t=='2')
            {
                menu(); 
            }
        }
 
    }while(1);
}
 
float Sum()
{
    monp head=NULL,p;
    float sum=0;
    head=ss();
    p=head;
    while(p!=NULL)
    {
        sum+=p->money;    //求和 
        p=p->next;
    }
    if(head==NULL)
        sum=0;
    return sum;
}
 
monp ss()    //求余額 
{
    FILE *fp;   //文件指針 
    monp p,head=NULL,p2,pre=NULL;
    int n=0;
    //float sum=0;
    fp=fopen(_name,"ab+");   //以只讀的方式打開名字為_name的二進制文件 
    if(fp==NULL)
    {
        printf("cannot open file");
    }
    else
    {
        while(!feof(fp))  //判斷標記是否移動到文件末尾 
        {
            n++;
            p=(monp)malloc(M);   //向內存申請一段空間 
            fread(p,M,1,fp);     //將fp所指向的文件中的一段大小為M的 內容賦給p 
            if(n==1)
            {
                head=p;
                p2=p;
            }
            else                //創建鏈表 
            {
                pre=p2;
                p2->next=p;
                p2=p;
            }
            p2->next=NULL;
        }
    }
    fclose(fp);     //關閉文件 
    if(pre!=NULL)
        pre->next=NULL;
    return(head);    //返回sum值 
}
 
void save_money(monp p)    //將p所指向的內容存入文件中 
{
    FILE *fp;    //文件指針 
    fp=fopen(_name,"ab");   //以追加的方式打開名字為_name的二進制文件 
    if(fp==NULL)
    {
        printf("cannot open file");
    }
    if(fwrite(p,M,1,fp)!=1)   //將p所指向的一段大小為M的內容存入fp所指向的文件中 
    {
        printf("write error");
    }
    fclose(fp);    //關閉文件  
}
 
void over()       //退出軟件 
{
    char t;
    toxy(48,11);
    printf("-----------------------");
    toxy(48,12);
    printf("|   您確定要退出嗎?  |");
    toxy(48,14);
    printf("| 1.確定     2.取消   |");
    toxy(48,15);
    printf("-----------------------");
    while(1)
    {
        t=getch();         //輸入t
        switch(t)
        {
            case '1':
            system("cls");
            color(6);
            toxy(48,10);
            printf("正在安全退出....");
            Sleep(1000);     //暫停1秒 
            system("cls");
            color(8);
            toxy(48,10);
            printf("已安全退出軟件");
            toxy(48,12);
            printf("謝謝使用!");
            toxy(48,14);
            printf("by-by^_^");
            exit(0);  break; //終止程序 
            case '2':
            menu(); break;   //調用函數,進入菜單 
            default :break;
        }
    }
}
 
main()    //簡潔明了的主函數~~~ 
{
    signin();   //調用函數 
}

感謝各位的閱讀,以上就是“C語言如何實現自動存取款機模擬系統”的內容了,經過本文的學習后,相信大家對C語言如何實現自動存取款機模擬系統這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

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

AI

咸阳市| 彭泽县| 朝阳县| 灵璧县| 桐城市| 南丰县| 都兰县| 贵定县| 南平市| 湘乡市| 繁峙县| 淅川县| 乃东县| 印江| 北安市| 上思县| 甘孜| 民乐县| 高邮市| 永春县| 淮南市| 南汇区| 栾城县| 舟山市| 额济纳旗| 吴桥县| 大名县| 小金县| 红原县| 临沭县| 大城县| 博罗县| 五寨县| 垫江县| 宣化县| 自贡市| 永济市| 嘉祥县| 灵武市| 依安县| 沁阳市|