c单机模拟一卡通系统

要求:

1.充值功能;

2.刷卡功能:公交刷卡,地铁刷卡,扣款;

3.配置功能:基本票价,公交车票折扣,地铁票折扣,学生票折扣的设置和调整

4.余额查询:余额不足报警系统

5.数据配置文件的保存,读取以及修改

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

typedef struct Bus
{
    int num;
    char name[20];
    int  money;
    int state;
    struct Bus * pnext;

} Bus;

int NUMBER=0;

Bus * Head = NULL;//链表头指针
Bus * End = NULL;

void Save()          //存入板块
{
    FILE * pfile=NULL;
    struct Bus * atemp=Head;
    if(atemp==NULL)
    {
        return;
    }
    pfile=fopen("一卡通.dat","wb");
    //以二进制格式打开一个文件只用于写入
    if(pfile==NULL)
    {
        printf("\n警告:用户数据丢失请检查!!!\n");
    }
    while(atemp!=NULL)
    {
        fwrite(atemp,sizeof(struct Bus),1,pfile);
        //是要输出数据的地址。
        //要写入的字节数;
        //要进行写入size字节的数据项的个数;
        //目标文件指针。
        atemp=atemp->pnext;
    }
    fclose(pfile);
}

void Read()          //读取文件
{
    int count=0;
    FILE *fp;
    if ((fp = fopen("一卡通.dat", "rb")) == NULL )
    {
        printf("\n警告:用户数据丢失请检查!!!\n");
        return;
    }
    else
    {
        while(!feof(fp))
        {
            Bus * atemp=(struct Bus *)malloc(sizeof(struct Bus));
            fread(atemp, sizeof(struct Bus), 1, fp);
            count++;
        }
        fp = fopen("公交一卡通.dat", "rb");
        while(count!=1)
        {
            Bus * atemp=(struct Bus *)malloc(sizeof(struct Bus));
            fread(atemp, sizeof(struct Bus), 1, fp);
            if (NULL==Head||NULL==End)    //排除只有头尾的情况
            {
                Head = atemp;              //链表为空,新节点即是头也是尾
                End = atemp;
            }
            else
            {
                End->pnext =atemp;       //新节点下一个指向尾
                End = atemp;            //新节点变成尾
            }
            count--;
        }
    }
    fclose(fp);
}

void loading()
{
    int k=1;
    for(; k<3; k++)
    {
        system("cls");
        printf("|        请稍等.                                                     | \n");
        printf("|        加载中:   --                                                | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等..                                                    | \n");
        printf("|        加载中:   \\                                                 | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等...                                                   | \n");
        printf("|        加载中:   ||                                                | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等....                                                  | \n");
        printf("|        加载中:   //                                                | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等.....                                                 | \n");
        printf("|        加载中:   --                                                | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等......                                                | \n");
        printf("|        加载中:   \\                                                 | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等......                                                | \n");
        printf("|        加载中:   ||                                                | \n");
        Sleep(200);
        system("cls");
        printf("|        请稍等......                                                | \n");
        printf("|        加载中:   //                                                | \n");
        Sleep(200);
        system("cls");
    }
}

void CreateList()     //创建板块
{
    Bus * ate
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值