c语言地铁收费程序,地铁收费系统C语言2 | 您所在的位置:网站首页 › 地铁消费系统代码 › 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
//卡号为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) { |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |