欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

關(guān)于經(jīng)典停車場問題指針輸出亂碼問題?

邀請好友加入騰訊云自媒體分享計劃
給好友發(fā)送邀請鏈接,好友成功加入計劃后你和好友都分別獲得 30 / 100 / 180 元云服務器代金
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
struct stackstruct /棧的結(jié)構(gòu)體/
{
int id;
int time;
struct stackstruct pre;
struct stackstruct
next;
};

創(chuàng)新互聯(lián)公司服務項目包括陽西網(wǎng)站建設、陽西網(wǎng)站制作、陽西網(wǎng)頁制作以及陽西網(wǎng)絡營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,陽西網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務的客戶以成都為中心已經(jīng)輻射到陽西省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!

struct queuestruct //隊列結(jié)構(gòu)體
{
int id;
struct queuestruct *next;
};

struct stackstruct stackhead1, stackend1;
struct stackstruct stackhead2, stackend2;
struct queuestruct queuehead, queueend;
int stack1count, stack2count; /棧中元素總數(shù)/
int queuecount; /隊列中元素總數(shù)/

void push(int flag, struct stackstruct p)
{
struct stackstruct
stack;
if (flag == 0) /棧1進棧操作/
{
if (stack1count == 0)//棧1空
{
stackhead1 = (struct stackstruct )malloc(sizeof(struct stackstruct));
stackhead1->id = p->id;
stackhead1->time = p->time;
stackhead1->next = NULL;
stackhead1->pre = NULL;
stackend1 = stackhead1;
}
else
{
stack = (struct stackstruct
)malloc(sizeof(struct stackstruct));
stack->id = p->id;
stack->time = p->time;
stackend1->next = stack;
stack->pre = stackend1;
stack->next = NULL;
stackend1 = stack;
}
stack1count++;
}
else if (flag == 1) /棧2進棧操作,棧1出棧/
{
if (stack2count == 0)//棧2空
{
stackhead2 = (struct stackstruct )malloc(sizeof(struct stackstruct));
stackhead2->id = p->id;
stackhead2->time = p->time;
stackhead2->next = NULL;
stackhead2->pre = NULL;
stackend2 = stackhead2;
}
else
{
stack = (struct stackstruct
)malloc(sizeof(struct stackstruct));
stack->id = p->id;
stack->time = p->time;
stackend2->next = stack;
stack->pre = stackend2;
stack->next = NULL;
stackend2 = stack;
}
stack2count++;
}
}

struct stackstruct pop(int id, int time)
{
struct stackstruct
stack;
stack = (struct stackstruct *)malloc(sizeof(struct stackstruct));

if (stackend1->id != id)
{
    stack->id = stackend1->id;
    stack->time = stackend1->time;
    stack->pre = stackend1->pre;
    stackend1=NULL;
    stackend1 = stack->pre;
    stackend1->next = NULL;
    stack1count--;
}
else
{
    stack->id = stackend1->id;
    stack->time = stackend1->time;
    stack->pre = stackend1->pre;
    printf("%d號汽車出停車場\n",id);
    printf("停車場停留時間: %d\n",time - stack->time);
    printf("應該繳納的費用(單價: 5): %d\n", 5 * (time - stack->time));
    stackend1=NULL;
    if (--stack1count == 0)
        stackend1 = stackhead1 = NULL;
    else
    {
        stackend1 = stack->pre;
        stackend1->next = NULL;
    }
    stack = NULL;
}
return stack;

}

struct stackstruct pop1()//棧2元素出棧
{
struct stackstruct
stack;
stack = (struct stackstruct *)malloc(sizeof(struct stackstruct));

stack->id = stackend2->id;
stack->time = stackend2->time;
stack->pre = stackend2->pre;
free(stackend2);
stackend2 = stack->pre;
stack2count--;

return stack;

}

void Enqueue(struct stackstruct p)//入隊
{
struct queuestruct
queue;
if (queuecount == 0)
{
queuehead = (struct queuestruct )malloc(sizeof(struct queuestruct));
queuehead->id = p->id;
queuehead->next = NULL;
queueend = queuehead;
}
else
{
queue = (struct queuestruct
)malloc(sizeof(struct queuestruct));
queue->id = p->id;
queue->next = NULL;
queueend->next = queue;
queueend = queue;
}
queuecount++;
}

struct stackstruct Dequeue(int time)//出隊
{
struct stackstruct
stack;
stack = (struct stackstruct *)malloc(sizeof(struct stackstruct));

stack->id = queuehead->id;
stack->time = time;
if (--queuecount == 0)
{
    queuehead = NULL;
    queueend = NULL;
}
else
    queuehead = queuehead->next;
return stack;

}
int main()
{
int n;
char s = {0};
struct stackstruct p;
printf("輸入狹長通道可停放汽車數(shù)量: ");
scanf_s("%d", &n);
getchar();
stack1count = stack2count = queuecount = 0;
p = (struct stackstruct
)malloc(sizeof(struct stackstruct));
printf("輸入停車信息:(動作,車牌號,時間)\n");
while (scanf_s("%c,%d%d", &s,1, &p->id, &p->time) != EOF)
{
if (s =='E')
{
printf("End");
break;
}
if (s =='A') /汽車到達/
{
if (stack1count < n) /棧未滿,進棧操作/
{
push(0, p);
printf("%d號汽車進入停車場\n",p->id);
printf("進入停車場時間: %d\n",stackend1->time);
printf("停車位置: %d\n",stack1count);
}
else /棧滿,進隊列操作/
{
Enqueue(p);
printf("%d號汽車進入便道\n",p->id);
printf("進入便道時間: %d\n",p->time);
printf("便道位置: %d\n",queuecount);
}
}
if (s =='D') /汽車離去/
{
struct stackstruct *temp;
while ((temp = pop(p->id, p->time)) != NULL)
{
push(1, temp);
}
while (stack2count != 0)
{
push(0, pop1());
}
if (queuecount != 0)
{
push(0, Dequeue(p->time));
printf("%d號汽車進入停車場\n",stackend1->id);
printf("進入時間: %d\n",stackend1->time);
printf("停車位置: %d\n",stack1count);
}
}
}
return 0;
}
我的博客即將同步至騰訊云+社區(qū),邀請大家一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=hiyc3ueo3ntk

新聞名稱:關(guān)于經(jīng)典停車場問題指針輸出亂碼問題?
文章位置:http://www.aaarwkj.com/article0/gihiio.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供響應式網(wǎng)站、品牌網(wǎng)站建設軟件開發(fā)、網(wǎng)站建設營銷型網(wǎng)站建設、微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設計公司
婷婷久久香蕉毛片毛片| 一区二区在线日韩视频| 欧美亚洲av一区二区三区| 中文字幕伦理一区二区| 一区二区三区人妻日韩| 麻豆视传媒官网免费观看| 国产成十人十综合十亚洲| 四虎在线永久观看视频| 欧美精品在线高清观看| 免费在线观看污污污网站| 亚洲欧美国产精品久久久| 日韩欧美国产一区二区精品| 免费草b视频在线观看| 欧美视频在线观看香蕉| 国产三级精品三级在线播放| 国产女人高潮流白丝视频| 美女露脸口爆吞精视频| 麻豆人妻少妇精品系列| 国产精品va在线观看入口| 精品一区无遮挡免费网站| 白白色手机视频免费看| 精品国内日本一区二区| 日韩中文字幕在线二区| 免费精品黑人一区二区三区| 91青青草原在线视频| 激情网站免费在线观看| 在线播放av男人的天堂| 国产亚洲一区二区三区午夜| 国产精品国产三级国产av野外| 亚洲免费小视频在线观看| 韩国三级网站在线观看视频| 精品人妻av区天天看片| 亚洲成人永久免费精品| 亚洲日本韩国在线免费| 国产欧美日韩国产精品| 美腿丝袜亚洲综合一区| 日韩中文字幕久久中文字幕| 日本东京热免一区二区| 亚洲av乱码一区二区三区观影| 国产精品欧美日韩一区| 日韩av高清在线播放|