c语言地铁收费程序,地铁收费系统C语言2

#include "stdio.h"

#include "string.h"

#include "stdlib.h"

#include "api.h"

#include "SubwayCharge.h"

#include "SubwayList.h"

HistoryInfoNode *g_historyInfoNodeHead =

NULL;

CardStat_EN g_CardStatusInfo[MAX_CARD_NUMBERS] =

{CARD_VALID};

void main(int argc, char* argv[])

{

apiServerStart(argc,

argv);

return;

}

void opResetProc(void)

{

int i = 0;

if(NULL != g_historyInfoNodeHead)

{

if(RET_OK != RemoveList(g_historyInfoNodeHead))

{

return;

}

g_historyInfoNodeHead = NULL;

}

g_historyInfoNodeHead = CreateList(); //创建链表头指针

if(NULL == g_historyInfoNodeHead)

{

return;

}

FILE *fp = NULL;

fp = fopen(FILENAME, "wa ");

if(NULL == fp)

{

apiPrintErrInfo(E99);

return;

}

fclose(fp);

for(i = 0; i < MAX_CARD_NUMBERS; i )

{

g_CardStatusInfo

blog_6e344d6b0102w6cz.html = CARD_VALID;

//卡号为0-9的可用

}

return;

}

void opChargeProc(TravelInfo_ST* pstTravelInfo)

{

//首先判断卡是否可用

if(CARD_UNVAILD ==

g_CardStatusInfo[pstTravelInfo->nCardNo])

{

apiPrintErrInfo(E22);

return;

}

//判断出站时间是否大于等于入站时间

if(apiTimeDiff(pstTravelInfo->nInHour,pstTravelInfo->nInMinute,pstTravelInfo->nOutHour,pstTravelInfo->nOutMinute)

> 0)

{

apiPrintErrInfo(E02);

apiWriteLog(0, pstTravelInfo, RET_ERROR);

return;

}

int nDistance = 0;

int flag = 0;

//计算两个站点之间的距离

flag =

apiGetDistanceBetweenTwoStation(pstTravelInfo->sInStation

,pstTravelInfo->sOutStation,

&nDistance);

if(RET_ERROR == flag)

{

apiPrintOpStatusInfo(I10,pstTravelInfo->nCardNo,

pstTravelInfo->nCardMoney);

apiWriteLog(0, pstTravelInfo, RET_ERROR);

return;

}

//计算基本票价

int nBasePrice = ComputeBasePrice(nDistance);

//计算扣费票价

int nChargePrice =

ComputeChargePrice(nBasePrice,pstTravelInfo);

//进行扣费,并将扣费记录写入链表尾

ChargeProcess(nChargePrice, pstTravelInfo);

return ;

}

void opQueryLogProc(QueryCond_ST* pstQueryCond)

{

if(NULL == pstQueryCond)

{

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值