printf("time is %f s\n",difftime(t_end,t_end));difftime中兩個(gè)都是t_end,注定為0。

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了索縣免費(fèi)建站歡迎大家使用!
以前做那個(gè)停車(chē)場(chǎng)管理系統(tǒng)的時(shí)候,也是需要計(jì)時(shí),因?yàn)橐召M(fèi)..好像就這么記得.每個(gè)上機(jī)的人,應(yīng)該有一個(gè)結(jié)構(gòu)體,在結(jié)構(gòu)體里設(shè)個(gè)計(jì)時(shí)的變量,可以是個(gè)只有兩個(gè)元素的數(shù)組.當(dāng)然這樣會(huì)很不方便了.(因?yàn)樾枰阕约狠斎肷蠙C(jī)時(shí)間,和下機(jī)時(shí)間,并保存在變量里.)....ANSIC里有一個(gè)time函數(shù),在time.h頭文件里.這個(gè)函數(shù),傳遞一個(gè)參數(shù),返回的是系統(tǒng)時(shí)間(單位我不清楚),返回的系統(tǒng)時(shí)間保存在你傳遞的參數(shù)里...你可以試試這個(gè).貌似這個(gè)可能就有點(diǎn)麻煩了.因?yàn)樾枰獪y(cè)試程序...你不可能等個(gè)1,2個(gè)小時(shí),再看看輸出結(jié)果是不是對(duì)的...測(cè)試的時(shí)候,乘個(gè)數(shù)放大一下應(yīng)該就可以了..也就是說(shuō),你設(shè)一個(gè)結(jié)構(gòu)體,里面有一個(gè)記錄時(shí)間的數(shù)組time[2],數(shù)組只含兩個(gè)元素,這兩個(gè)元素的值,由time函數(shù)來(lái)獲得.(這里獲得的是系統(tǒng)時(shí)間)..這個(gè)結(jié)構(gòu)體里應(yīng)該還含有的其他元素,應(yīng)該要包括,電腦標(biāo)號(hào)ID(每個(gè)電腦對(duì)應(yīng)一個(gè)號(hào)碼),和一個(gè)bool型變量status,來(lái)標(biāo)識(shí)是該電腦的狀態(tài),已有人上機(jī)或者處于空閑狀態(tài).status為true(有人使用該機(jī)器)時(shí),把系統(tǒng)時(shí)間付給time[0],該機(jī)器的status變?yōu)閒alse(有人下機(jī))后,在把一個(gè)系統(tǒng)時(shí)間付給time[1].計(jì)算時(shí)間差和收費(fèi)額...那些一個(gè)小時(shí),半個(gè)小時(shí),等等,不同時(shí)間的不同收費(fèi)標(biāo)準(zhǔn),一般用if,什么的來(lái)搞定.
/*----------------------------------------------------------------
// Copyright (C) 2009 沈陽(yáng)工程學(xué)院信息安全工作室
// 版權(quán)所有。
//
// 文件名:模擬停車(chē)場(chǎng)問(wèn)題.cpp
// 文件功能描述:模擬停車(chē)場(chǎng)問(wèn)題
//
//
// 創(chuàng)建標(biāo)識(shí):20091214
//
// 修改標(biāo)識(shí):20091218
// 修改描述:完成編碼
//----------------------------------------------------------------*/
//頭文件
#include iostream
#include malloc.h
#include string
#include windows.h
//常量定義
#define MAX_STOP 4 //定義停車(chē)場(chǎng)最大停車(chē)數(shù)
#define MAX_PLATE 10 //定義車(chē)牌號(hào)最大長(zhǎng)度
#define TIME_COUNT "秒" //定義時(shí)間單位
#define TIME_MS_TO_CONUT 1000 //定義時(shí)間進(jìn)制,意為由TIME_COUNT到毫秒的進(jìn)制
#define UNIT_PRICE 10 //定義單位時(shí)間收費(fèi)標(biāo)準(zhǔn)
using namespace std; //使用std命名空間
//數(shù)據(jù)結(jié)構(gòu)定義
//定義存儲(chǔ)汽車(chē)信息的結(jié)構(gòu)體
typedef struct
{
char license_plate[MAX_PLATE]; //汽車(chē)牌照號(hào)碼,定義為一個(gè)字符指針類(lèi)型
char state; //汽車(chē)當(dāng)前狀態(tài),字符p表示停放在停車(chē)位上,字符s表示停放在便道上,每輛車(chē)的初始狀態(tài)用字符i來(lái)進(jìn)行表示
int time; //汽車(chē)停入停車(chē)場(chǎng)時(shí)的時(shí)間,用來(lái)計(jì)時(shí)收費(fèi)
}CAR;
//定義模擬停車(chē)場(chǎng)的棧結(jié)構(gòu)
typedef struct
{
CAR STOP[MAX_STOP]; //汽車(chē)信息的存儲(chǔ)空間
int top; //用來(lái)指示棧頂位置的靜態(tài)指針
}SeqStack;
//定義模擬便道的隊(duì)列結(jié)構(gòu)
typedef struct node
{
CAR WAIT; //汽車(chē)信息的存儲(chǔ)空間
struct node *next; //用來(lái)指示隊(duì)列位置的動(dòng)態(tài)指針
}QNode; //鏈隊(duì)列節(jié)點(diǎn)的類(lèi)型
//定義鏈隊(duì)列的收尾指針
typedef struct
{
QNode *front,*rear;
}LQueue; //將頭尾指針?lè)庋b在一起的鏈隊(duì)
//函數(shù)聲明
int Empty_LQueue(LQueue *q); //判隊(duì)空
int LeaveCheck(SeqStack parking , char *license_plate); //檢查離開(kāi)的車(chē)是否在停車(chē)場(chǎng)中
int QueueLength(LQueue *q); //判隊(duì)長(zhǎng)度
int Out_LQueue(LQueue *sidewalk , char *license_plate); //出隊(duì)操作
int StackEmpty(SeqStack parking); //判斷棧是否為空
int StackFull(SeqStack parking); //判斷棧是否為滿
int StackPop(SeqStack parking); //出棧操作
int StackTop(SeqStack parking , char *license_plate , int time);//取棧頂元素
void Car_come(SeqStack parking , LQueue *sidewalk); //有車(chē)到來(lái)時(shí)的操作
void Car_leave(SeqStack parking , LQueue *sidewalk); //有車(chē)離開(kāi)的操作
void Display(SeqStack parking); //顯示停車(chē)場(chǎng)內(nèi)的所有信息 調(diào)試時(shí)用
void InitStack(SeqStack parking); //初始化棧
void InitList(LQueue *sidewalk); //初始化隊(duì)列
void In_LQueue(LQueue *sidewalk , char *license_plate); //進(jìn)隊(duì)操作
void Input_Check(char *license_plate); ////檢驗(yàn)輸入的車(chē)牌是否合法
void StackPush(SeqStack parking , char *license_plate , int stop_time);//進(jìn)棧操作
void main()
{
//定義變量
SeqStack parking;
LQueue *sidewalk = NULL;
char *choice = new char;
int flag = 1; //定義一個(gè)變量 判斷是否退出
//初始化一個(gè)為空的停車(chē)場(chǎng)
InitStack(parking);
//初始化一個(gè)為空的便道
InitList(sidewalk);
//運(yùn)行界面及功能選擇
while(flag)
{
cout"\n\t 停車(chē)場(chǎng)模擬管理系統(tǒng) \n\n";
cout"\t|--------------------------------------------------|\n\n";
cout"\t|本程序?yàn)橥\?chē)場(chǎng)的模擬管理系統(tǒng),有車(chē)到來(lái)時(shí)請(qǐng)按C鍵。|\n\n";
cout"\t|然后根據(jù)屏幕提示進(jìn)行相關(guān)操作,有車(chē)要走時(shí)請(qǐng)按l鍵。|\n\n";
cout"\t|然后根據(jù)屏幕提示進(jìn)行相關(guān)操作,查看停車(chē)場(chǎng)請(qǐng)按D鍵。|\n\n";
cout"\t|然后根據(jù)屏幕提示進(jìn)行相關(guān)操作,要退出系統(tǒng)請(qǐng)按Q鍵。|\n\n";
cout"\t|--------------------------------------------------|\n\n";
cout"請(qǐng)選擇操作:";
gets(choice);
if(1 != strlen(choice))
{
cout"請(qǐng)正確輸入選項(xiàng)!";
continue;
}
else
{
switch(*choice)
{
case 'c':
case 'C':
{
Car_come(parking,sidewalk);break;
}
case 'l':
case 'L':
{
Car_leave(parking,sidewalk);break;
}
case 'q':
case 'Q':
{
flag=0;break;
}
case 'd':
case 'D':
{
Display(parking);break;
}
default:
cout"選擇不正確!請(qǐng)重新選擇!\n";
}
}
}
}
//有車(chē)到來(lái)時(shí)的操作
void Car_come(SeqStack parking , LQueue *sidewalk)
{
//定義變量
char license_plate[MAX_PLATE];
cout"請(qǐng)輸入車(chē)輛的車(chē)牌號(hào)碼:";
Input_Check(license_plate);
//判斷停車(chē)場(chǎng)是否已滿,滿則進(jìn)入便道,不滿進(jìn)入停車(chē)場(chǎng)
if(StackFull(parking))
{
In_LQueue(sidewalk , license_plate); //進(jìn)入便道
cout"停車(chē)場(chǎng)已滿請(qǐng)?jiān)诒愕赖群?您的位置為"QueueLength(sidewalk)
endl;
}
else
{
StackPush(parking , license_plate , GetTickCount()); //進(jìn)入停車(chē)場(chǎng)
cout"請(qǐng)進(jìn)入停車(chē)場(chǎng)中的"parking.top+1"號(hào)停車(chē)位\n";
}
// Display(parking);
}
//有車(chē)離開(kāi)時(shí)的操作
void Car_leave(SeqStack parking , LQueue *sidewalk)
{
//定義變量
SeqStack tmpparking; //定義臨時(shí)停車(chē)場(chǎng)
char leave_license_plate[MAX_PLATE]; //要離開(kāi)的車(chē)牌號(hào)
char license_plate[MAX_PLATE]; //存放從停車(chē)場(chǎng)中讀出來(lái)的車(chē)牌信息
int time;
InitStack(tmpparking); //初始化臨時(shí)停車(chē)場(chǎng)
//判斷停車(chē)場(chǎng)中是否有車(chē)
if(StackEmpty(parking))
{
cout"當(dāng)前停車(chē)場(chǎng)中沒(méi)有車(chē)\n";
return; //退出子函數(shù)
}
cout"請(qǐng)輸入要離開(kāi)的車(chē)牌照:";
Input_Check(leave_license_plate);
cout"當(dāng)前停車(chē)場(chǎng)中有"parking.top+1"輛車(chē)\n";
if(LeaveCheck(parking , leave_license_plate)) //判斷車(chē)是否在停車(chē)場(chǎng)中
{
//車(chē)在停車(chē)場(chǎng)中
cout"您的車(chē)在"LeaveCheck(parking , leave_license_plate)"號(hào)車(chē)位上\n";
while(StackTop(parking , license_plate , time)
(strcmp(parking.STOP[parking.top].license_plate , leave_license_plate) != 0))
{
strcpy(parking.STOP[parking.top].license_plate , license_plate);
cout"牌照為"license_plate"的車(chē)暫時(shí)退出停車(chē)場(chǎng)"parking.top+1"號(hào)位\n";
StackPush(tmpparking , license_plate , time); //停車(chē)場(chǎng)中的車(chē)暫時(shí)退出 進(jìn)入臨時(shí)停車(chē)場(chǎng)
StackPop(parking); //出棧
}
cout"牌照為"license_plate"的車(chē)離開(kāi)停車(chē)場(chǎng)"parking.top+1"號(hào)位\n";
cout"您在停車(chē)場(chǎng)中停了"(GetTickCount()-time)/TIME_MS_TO_CONUTTIME_COUNTendl; //輸出所停時(shí)間信息
cout"應(yīng)繳費(fèi)用為"(GetTickCount()-time)/TIME_MS_TO_CONUT*UNIT_PRICE"元\n" //輸出費(fèi)用信息
StackPop(parking); //出棧
//將臨時(shí)停車(chē)場(chǎng)中的車(chē)停回停車(chē)場(chǎng)
while(StackEmpty(tmpparking) != 1)
{
StackTop(tmpparking , license_plate , time);
StackPush(parking , license_plate , time);
cout"牌照為"license_plate"的車(chē)進(jìn)入停車(chē)場(chǎng)"parking.top+1"號(hào)位\n";
license_plate[0] = '\0';
StackPop(tmpparking);
}
if(parking.top+1 == MAX_STOP-1) //判斷車(chē)離開(kāi)前停車(chē)場(chǎng)是否停滿
if(QueueLength(sidewalk)) //如果停滿則判斷便道上是否有車(chē)
{
//便道中有車(chē) 則從便道中停入停車(chē)場(chǎng)
Out_LQueue(sidewalk , license_plate); //出隊(duì)
StackPush(parking , license_plate , GetTickCount()); //入棧
cout"在便道中牌照為"license_plate"的車(chē)進(jìn)入停車(chē)場(chǎng)"parking.top+1"號(hào)位\n";
}
}
else
//車(chē)不在停車(chē)場(chǎng)中
cout"您的車(chē)不在停車(chē)場(chǎng)中!\n";
}
//初始化順序棧
void InitStack(SeqStack parking)
{
parking.top = -1;
}
//判棧空
int StackEmpty(SeqStack parking)
{
if(parking.top == -1)
return 1;
else
return 0;
}
//判棧滿
int StackFull(SeqStack parking)
{
if(parking.top == MAX_STOP-1)
return 1;
else
return 0;
}
//入棧
void StackPush(SeqStack parking , char *license_plate , int stop_time)
{
parking.top++;
strcpy(parking.STOP[parking.top].license_plate , license_plate);
parking.STOP[parking.top].state = 'p';
parking.STOP[parking.top].time = stop_time;
}
//出棧 返回棧頂指針
int StackPop(SeqStack parking)
{
if(StackEmpty(parking))
return 0;
else
return parking.top--;
}
//取棧頂元素
int StackTop(SeqStack parking , char *license_plate , int time)
{
if(StackEmpty(parking))
return 0;
else
{
strcpy(license_plate , parking.STOP[parking.top].license_plate);
time = parking.STOP[parking.top].time;
return 1;
}
}
//顯示所有
void Display(SeqStack parking)
{
if(parking.top == -1)
printf("停車(chē)場(chǎng)為空\(chéng)n");
else
{
while(parking.top != -1)
{
cout"車(chē)牌號(hào)為:"parking.STOP[parking.top].license_plate;
cout",停在"parking.top + 1 "號(hào)車(chē)位上";
cout",已停"(GetTickCount()-parking.STOP[parking.top].time)/TIME_MS_TO_CONUTTIME_COUNTendl;
parking.top--;
}
}
}
//初始化隊(duì)列
void InitList(LQueue *sidewalk)
{
sidewalk = (LQueue *)malloc(sizeof(LQueue));
sidewalk-front=sidewalk-rear = NULL;
}
//入隊(duì)
void In_LQueue(LQueue *sidewalk,char *license_plate)
{
QNode *car_on_sidewalk;
car_on_sidewalk = (QNode *)malloc(sizeof(QNode)); //為新節(jié)點(diǎn)開(kāi)辟新空間
strcpy(car_on_sidewalk-WAIT.license_plate , license_plate); //將數(shù)據(jù)寫(xiě)入節(jié)點(diǎn)
car_on_sidewalk-WAIT.state = 's'; //寫(xiě)入停車(chē)信息
car_on_sidewalk-WAIT.time = GetTickCount(); //寫(xiě)入停車(chē)時(shí)間
car_on_sidewalk-next = NULL;
if(Empty_LQueue(sidewalk)) //隊(duì)空則創(chuàng)建第一個(gè)節(jié)點(diǎn)
sidewalk-front = sidewalk-rear = car_on_sidewalk;
else
{
//隊(duì)非空插入隊(duì)尾
sidewalk-rear-next = car_on_sidewalk;
sidewalk-rear = car_on_sidewalk;
}
}
//判隊(duì)空
int Empty_LQueue(LQueue *q)
{
if(q-front == NULL)
return 1;
else
return 0;
}
//判隊(duì)長(zhǎng)度 返回隊(duì)長(zhǎng)
int QueueLength(LQueue *q)
{
QNode *p=q-front;
int i=0;
while(p != NULL)
{
i++;
p=p-next;
}
return i;
}
//出隊(duì) 成功返回1 隊(duì)空返回0
int Out_LQueue(LQueue *sidewalk,char *license_plate)
{
QNode *car_on_sidewalk;
if(Empty_LQueue(sidewalk)) //如果隊(duì)空返回0
return 0;
car_on_sidewalk = sidewalk-front;
strcpy(license_plate , car_on_sidewalk-WAIT.license_plate);//取出隊(duì)頭元素
if(sidewalk-front == sidewalk-rear) //隊(duì)中只有一個(gè)元素
sidewalk-front = sidewalk-rear=NULL; //刪除元素
else
sidewalk-front = sidewalk-front-next; //隊(duì)頭指針后移
free(car_on_sidewalk); //釋放指針
return 1;
}
//檢查離開(kāi)的車(chē)是否在停車(chē)場(chǎng)中 返回車(chē)在停車(chē)場(chǎng)中位置 不在則返回0
int LeaveCheck(SeqStack parking,char *license_plate)
{
int flag = parking.top+1; //定義變量記錄當(dāng)前車(chē)在停車(chē)場(chǎng)中位置
if(StackEmpty(parking))
return 0;
else
{
//查找離開(kāi)車(chē)所在位置
while(parking.top != -1 strcmp(parking.STOP[parking.top].license_plate , license_plate) != 0)
{
flag--;
parking.top--;
}
return flag;
}
}
//檢驗(yàn)輸入的車(chē)牌是否合法
void Input_Check(char *license_plate)
{
int flag = 1;
int i;
string tmpstr;
while(flag)
{
cintmpstr;
getchar();
if(tmpstr.length()MAX_PLATE)
{
for(i=0;i10;i++)
license_plate[i] = tmpstr.c_str()[i];
flag = 0;
}
else
cout"輸入有誤,請(qǐng)重新輸入:";
}
}
以前的課設(shè) 你看看吧 純手工的~~
#include stdio.h
#include stdlib.h
#include string.h
#include time.h
#define max 3
#define price 1
int b=1;
typedef struct
{
int day;
int hour;
int min;
}TIME; //時(shí)間結(jié)點(diǎn)
typedef struct
{
char num[10]; //車(chē)牌號(hào)
TIME time; //進(jìn)入停車(chē)場(chǎng)的時(shí)間
int n; //進(jìn)入停車(chē)場(chǎng)的位置
}information;
//棧結(jié)構(gòu)體定義
typedef struct node
{
information data;
struct node *next;
}stacknode; stacknode *top1,*top2;
//隊(duì)列結(jié)構(gòu)體定義
typedef struct
{
information data;
stacknode *front,*rear;
}LQueue;LQueue *Q;
//函數(shù)聲明部分/////////////////////////////////////////////////////////
stacknode *Init(); //棧的初始化
stacknode *into(stacknode *top1,LQueue *Q); //初始化車(chē)輛進(jìn)入
int expenses(stacknode *p,int x,int y); //停車(chē)費(fèi)用計(jì)算函數(shù)
stacknode *leave(stacknode *top1,char str[],LQueue *Q); //車(chē)輛駛出出場(chǎng)函數(shù)
LQueue *InitLQue(); //初始化隊(duì)列函數(shù)
LQueue *wait(LQueue *q,stacknode *s); //車(chē)輛進(jìn)入候車(chē)便道函數(shù)
int EmptyLQue(LQueue *q); //判斷候車(chē)便道有無(wú)等待車(chē)輛函數(shù)
stacknode *out(LQueue *q); //候車(chē)區(qū)車(chē)輛出隊(duì)
stacknode *LQinto(stacknode *p,stacknode *top1); //從候車(chē)便道進(jìn)入停車(chē)場(chǎng)函數(shù)
void show(stacknode *top1); //顯示停車(chē)場(chǎng)所有信息函數(shù)
void T_shou(LQueue *Q); //顯示候車(chē)區(qū)信息
/*函數(shù)部分*/
//主函數(shù)
void main()
{
char str[10];
Q=InitLQue();
top1=Init();
top2=Init();
Q=InitLQue();
int i;
printf("\t\t\t*************************************\n");
printf("\t\t\t\t 停車(chē)場(chǎng)管理系統(tǒng)\n");
printf("\t\t\t|| 1. 車(chē)輛進(jìn)入停車(chē)場(chǎng) ||\n");
printf("\t\t\t|| 2. 車(chē)輛離開(kāi)停車(chē)場(chǎng) ||\n");
printf("\t\t\t|| 3. 顯示停車(chē)場(chǎng)內(nèi)所有車(chē)輛信息 ||\n");
printf("\t\t\t|| 4. 顯示候車(chē)區(qū)內(nèi)所有車(chē)輛信息 ||\n");
printf("\t\t\t|| 5. 退出 ||\n");
printf("\t\t\t*************************************\n");
while(i!=5)
{
printf("\t請(qǐng)輸入選項(xiàng)1-5:");
scanf("%d",i);
switch(i)
{
case 1:
top1=into(top1,Q);
break;
case 2:
printf("請(qǐng)輸入離開(kāi)車(chē)輛的車(chē)牌號(hào):");
scanf("%s",str);
top1=leave(top1,str,Q);
break;
case 3:show(top1);break;
case 4:T_shou(Q);break;
case 5:exit(1);
default:printf("輸入錯(cuò)誤,請(qǐng)重新輸入1—5:");
break;
}
}
}
/*子函數(shù)*/
//初始化
stacknode *Init()
{
stacknode *top;
top=(stacknode *)malloc(sizeof(stacknode));
top=NULL;
return top;
}
//初始化車(chē)輛進(jìn)入
stacknode *into(stacknode *top1,LQueue *Q)
{
stacknode *p,*q;
time_t rawtime; //調(diào)用系統(tǒng)時(shí)間函數(shù)
struct tm *timeinfo; //時(shí)間結(jié)點(diǎn)
time(rawtime);
timeinfo=localtime(rawtime);
p=(stacknode *)malloc(sizeof(stacknode));
if(p==NULL)
{
printf("內(nèi)存分配失敗");
return top1;
}
printf("請(qǐng)輸入進(jìn)入停車(chē)場(chǎng)車(chē)輛的車(chē)牌號(hào):");
scanf("%s",p-data.num);
q=top1;
while(q!=NULL)
{
if(strcmp(p-data.num,q-data.num)==0)
{
printf("車(chē)牌號(hào)輸入有誤,該車(chē)已進(jìn)入!");
return top1;
}
q=q-next;
}
p-data.time.day=timeinfo-tm_mday;
p-data.time.hour=timeinfo-tm_hour;
p-data.time.min=timeinfo-tm_min;
p-data.n=b;
if(bmax)
{
printf("停車(chē)場(chǎng)已滿,請(qǐng)?jiān)诒愕赖群?\n");
wait(Q,p);
return top1;
}
if(top1==NULL)
{
p-next=NULL;
top1=p;
}
else
{
p-next=top1;
top1=p;
}
b++;
printf("車(chē)輛進(jìn)入停車(chē)場(chǎng)成功,時(shí)間已經(jīng)自動(dòng)載入!\n");
printf("車(chē)牌為%s的汽車(chē)駛?cè)霑r(shí)間為:%d號(hào)%d點(diǎn)%d分\n",top1-data.num,top1-data.time.day,top1-data.time.hour,top1-data.time.min);
return top1;
}
//停車(chē)費(fèi)用計(jì)算函數(shù)
int expenses(stacknode *p,int x1,int x2,int x3)
{
int w;
if(x3!=0)
w=(x1*24+x2+1-(p-data.time.day*24+p-data.time.hour))*price;
else
w=(x1*24+x2-(p-data.time.day*24+p-data.time.hour))*price;
return w;
}
//車(chē)輛駛出出場(chǎng)函數(shù)
stacknode *leave(stacknode *top1,char str[],LQueue *Q)
{
int i,day,hour,min;
time_t rawtime;
struct tm *timeinfo;
time(rawtime);
timeinfo=localtime(rawtime);
day=timeinfo-tm_mday;
hour=timeinfo-tm_hour;
min=timeinfo-tm_min;
stacknode *p,*q;
if(top1==NULL)
{
printf("停車(chē)場(chǎng)沒(méi)有車(chē)輛!\n");
return top1;
}
q=(stacknode *)malloc(sizeof(stacknode));
if(p==NULL)
{
printf("內(nèi)存分配失敗");
return top1;
}
q=top1;
while(q!=NULL)
{
if(strcmp(q-data.num,str)==0)
break;
q=q-next;
}
if(q==NULL)
{
printf("輸入有誤,該車(chē)輛不在停車(chē)場(chǎng)!\n");
return top1;
}
for(i=top1-data.n;iq-data.n;i--)
{
p=(stacknode *)malloc(sizeof(stacknode));
if(p==NULL)
{
printf("內(nèi)存分配失敗");
return top1;
}
strcpy(p-data.num,top1-data.num);
p-data.time=top1-data.time;
p-data.n=top1-data.n-1;
top1=top1-next;
if(top2==NULL)
{
p-next=NULL;
top2=p;
}
else
{
p-next=top2;
top2=p;
}
}
top1=top1-next;
while(top2!=NULL)
{
p=(stacknode *)malloc(sizeof(stacknode));if(p==NULL){printf("內(nèi)存分配失敗");return top1;}
p-data.n=top2-data.n;
strcpy(p-data.num,top2-data.num);
p-data.time=top2-data.time;
p-next=top1;
top1=p;
top2=top2-next;
}
if(EmptyLQue(Q))
{
p=out(Q);
p-data.n--;
top1=LQinto(p,top1);
}
else
b--;
printf("車(chē)牌為%s的汽車(chē)駛出時(shí)間為:%d號(hào)%d點(diǎn)%d分\n",q-data.num,day,hour,min);
printf("車(chē)輛駛出停車(chē)場(chǎng)需要繳納的費(fèi)用為:%d元\n",expenses(q,day,hour,min));
return top1;
}
//隊(duì)列函數(shù)初始化
LQueue *InitLQue()
{
LQueue *Q;
stacknode *p;
Q=(LQueue *)malloc(sizeof(LQueue));
p=(stacknode *)malloc(sizeof(stacknode));
p-next=NULL;
Q-front=Q-rear=p;
return Q;
}
//候車(chē)區(qū)隊(duì)列入隊(duì)
LQueue *wait(LQueue *q,stacknode *s)
{
s-next=NULL;
q-rear-next=s;
q-rear=s;
return q;
}
//判斷候車(chē)便道有無(wú)車(chē)輛等待
int EmptyLQue(LQueue *q)
{
if(q-front==q-rear)
return 0;
else
return 1;
}
//候車(chē)區(qū)車(chē)輛出隊(duì)
stacknode *out(LQueue *q)
{
stacknode *p;
p=q-front-next;
if(q-front-next==q-rear)
{
q-rear=q-front;
return p;
}
else
q-front-next=p-next;
p-next=NULL;
return p;
}
//候車(chē)隊(duì)列進(jìn)入停車(chē)場(chǎng)
stacknode *LQinto(stacknode *p,stacknode *top1)
{
p-next=top1;
top1=p;
return top1;
}
//顯示停車(chē)場(chǎng)內(nèi)所有車(chē)輛信息
void show(stacknode *top1)
{
printf(" 停車(chē)場(chǎng)內(nèi)全部車(chē)輛信息表\n");
if(top1==NULL)
printf(" 停車(chē)場(chǎng)內(nèi)無(wú)車(chē)!\n");
else
{
printf("車(chē)牌號(hào) 進(jìn)入時(shí)間 位置\n");
while(top1!=NULL)
{
printf(" %s %d號(hào)%d點(diǎn)%d分 第%d位\n",top1-data.num,top1-data.time.day,top1-data.time.hour,top1-data.time.min,top1-data.n);
top1=top1-next;
}
}
}
//顯示候車(chē)區(qū)的汽車(chē)信息
void T_shou(LQueue *Q)
{
LQueue *q;
q=(LQueue *)malloc(sizeof(LQueue));
q-rear=Q-rear-next;
printf(" 候車(chē)區(qū)信息\n");
if(q-front==q-rear)
printf("候車(chē)區(qū)沒(méi)有車(chē)輛!\n");
else
{
printf("車(chē)牌號(hào) 進(jìn)入時(shí)間\n");
while(q!=NULL)
{
printf("%s %d號(hào)%d點(diǎn)%d分",q-data.num,q-data.time.day,q-data.time.hour,q-data.time.min);
q-rear=q-rear-next;
}
}
}
/*時(shí)間函數(shù)
int timef()
{
int x,y;
time_t rawtime;
struct tm *timeinfo;
time(rawtime);
timeinfo=localtime(rawtime);
x=timeinfo-tm_mday,y=timeinfo-tm_hour;
}
time_t rawtime;
struct tm *timeinfo;
time(rawtime);
timeinfo=locoltime(rawtime);
timeinfo-tm_ymday,*/
                文章題目:停車(chē)場(chǎng)計(jì)時(shí)收費(fèi)函數(shù)c語(yǔ)言 c語(yǔ)言停車(chē)場(chǎng)收費(fèi)系統(tǒng)管理
                
                文章URL:http://www.yijiale78.com/article34/ddgcgpe.html
            
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)、標(biāo)簽優(yōu)化、網(wǎng)頁(yè)設(shè)計(jì)公司、微信小程序、ChatGPT、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)