




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、*大學(xué)人工智能基礎(chǔ)課程實(shí)驗(yàn)報(bào)告(2011-2012學(xué)年第一學(xué)期)啟發(fā)式搜索 王浩算法班 級: * 學(xué) 號: * 姓 名: * 指導(dǎo)教師: * 成 績: 2012年 1 月 10 日實(shí)驗(yàn)一 啟發(fā)式搜索算法1. 實(shí)驗(yàn)內(nèi)容:使用啟發(fā)式搜索算法求解8數(shù)碼問題。 編制程序?qū)崿F(xiàn)求解8數(shù)碼問題算法,采用估價(jià)函數(shù),其中:是搜索樹中結(jié)點(diǎn)的深度;為結(jié)點(diǎn)的數(shù)據(jù)庫中錯(cuò)放的棋子個(gè)數(shù);為結(jié)點(diǎn)的數(shù)據(jù)庫中每個(gè)棋子與其目標(biāo)位置之間的距離總和。 分析上述中兩種估價(jià)函數(shù)求解8數(shù)碼問題的效率差別,給出一個(gè)是的上界的的定義,并測試使用該估價(jià)函數(shù)是否使算法失去可采納性。2. 實(shí)驗(yàn)?zāi)康氖炀氄莆諉l(fā)式搜索算法及其可采納性。3. 實(shí)驗(yàn)原理 使
2、用啟發(fā)式信息知道搜索過程,可以在較大的程度上提高搜索算法的時(shí)間效率和空間效率;啟發(fā)式搜索的效率在于啟發(fā)式函數(shù)的優(yōu)劣,在啟發(fā)式函數(shù)構(gòu)造不好的情況下,甚至在存在解的情形下也可能導(dǎo)致解丟失的現(xiàn)象或者找不到最優(yōu)解,所以構(gòu)造一個(gè)優(yōu)秀的啟發(fā)式函數(shù)是前提條件。4.實(shí)驗(yàn)內(nèi)容 1.問題描述 在一個(gè)3*3的九宮格 里有1至8 八個(gè)數(shù)以及一個(gè)空格隨機(jī)擺放在格子中,如下圖:1 2 38 0 47 6 52 8 3 1 6 47 0 5 初始狀態(tài) 目標(biāo)狀態(tài)現(xiàn)需將圖一轉(zhuǎn)化為圖二的目標(biāo)狀態(tài),調(diào)整的規(guī)則為:每次只能將空格與其相鄰的一個(gè)數(shù)字進(jìn)行交換。實(shí)質(zhì)是要求給出一個(gè)合法的移動(dòng)步驟,實(shí)現(xiàn)從初始狀態(tài)到目標(biāo)狀態(tài)的轉(zhuǎn)變。2.算法分析
3、 (1)解存在性的討論 對于任意的一個(gè)初始狀態(tài),是否有解可通過線性代數(shù)的有關(guān)理論證明。按數(shù)組存儲后,算出初始狀態(tài)的逆序數(shù)和目標(biāo)狀態(tài)的逆序數(shù),若兩者的奇偶性一致,則表明有解。(2)估價(jià)函數(shù)的確定通過對八數(shù)碼的特性的研究,找出一個(gè)相對好的函數(shù),f(n)=d(n)+h(n)其中h(n)=2*compare(n)+3*S(n);d(n)為已搜索的深度;(compare(n)為當(dāng)前節(jié)點(diǎn)與目標(biāo)結(jié)點(diǎn)相同位置不相同的個(gè)數(shù),S(n)為當(dāng)前節(jié)點(diǎn)的無序度。)(3)節(jié)點(diǎn)的處理 取得一個(gè)結(jié)點(diǎn)后,判斷是否有解,然后對其進(jìn)行擴(kuò)展,用估價(jià)函數(shù)從中取得一個(gè)最優(yōu)節(jié)點(diǎn),依次循環(huán)將路徑得到,直到取的最后的目標(biāo)狀態(tài)。 (4)算法設(shè)計(jì)
4、a.輸入初始結(jié)點(diǎn),判斷解的存在性,并與目標(biāo)節(jié)點(diǎn)對比。 b.若不是目標(biāo)節(jié)點(diǎn)則進(jìn)行擴(kuò)展,生成其全部后繼節(jié)點(diǎn)。 c.對于每個(gè)后繼節(jié)點(diǎn)均求其f(n),并比較。d.將最小f(n)存入正確路徑,并與目標(biāo)節(jié)點(diǎn)進(jìn)行對比。e.若不是目標(biāo)節(jié)點(diǎn)則循環(huán)執(zhí)行b,若是目標(biāo)節(jié)點(diǎn)則輸出5實(shí)驗(yàn)結(jié)果輸入輸出:源代碼如下:#include<stdio.h>int final9=1,2,3,8,0,4,7,6,5;/目標(biāo)狀態(tài)節(jié)點(diǎn)int a10009,c9,e9,f9;/路徑節(jié)點(diǎn)和擴(kuò)展節(jié)點(diǎn)int deep=1,fn;/深度和估計(jì)值int b9;char moveaction;/移動(dòng)方向int fnjisuan(int b9
5、)/估價(jià)函數(shù)int compare=0,s=0,fn1,d9;d0=b0;d1=b1;d2=b2;d3=b5;d4=b8;d5=b7;d6=b6;d7=b3;d8=b4;for(int i=0;i<9;i+)if(bi!=finali&&i!=4)compare+;for(i=0;i<7;i+)if(di+1-di)!=1)s+;fn1=2*compare+3*s+deep;/估價(jià)函數(shù)計(jì)算結(jié)果return fn1;void show(int c9)/輸出節(jié)點(diǎn)for(int i=0;i<9;i+)adeepi=ci;for(i=0;i<9;i+)if(i)
6、%3=0)printf("n");printf("%dt",ci);deep+;printf("n");int jingguo(int e9)/測試當(dāng)前節(jié)點(diǎn)是否已經(jīng)經(jīng)過 避免回溯for(int i=0;i<deep;i+)int k=0;for(int j=0;j<9;j+)if(ej=aij)k+;if(k=9)return 0;return 1;int move_up(int c9,int Zerosign)/上移操作for(int i=0;i<9;i+)ci=bi;cZerosign=cZerosign-3;
7、cZerosign-3=0;int fn1=fnjisuan(c);return fn1;int move_down(int c9,int Zerosign)/下移操作 for(int i=0;i<9;i+)ci=bi;cZerosign=cZerosign+3; cZerosign+3=0; int fn1=fnjisuan(c);return fn1;int move_left(int c9,int Zerosign)/左移操作 for(int i=0;i<9;i+)ci=bi;cZerosign=cZerosign-1; cZerosign-1=0; int fn1=fnji
8、suan(c);return fn1;int move_right(int c9,int Zerosign)/右移操作for(int i=0;i<9;i+)ci=bi;cZerosign=cZerosign+1; cZerosign+1=0;int fn1=fnjisuan(c); return fn1;int zuixiao(int fn1,int fn2,int fn3,int fn4)/求最小值int f1,f2,f3;f1=(fn1<=fn2)?fn1:fn2;f2=(fn3<=fn4)?fn3:fn4;f3=(f1<=f2)?f1:f2;return f3;i
9、nt cixiao(int fn1,int fn2,int fn3,int fn4)/求次小值int f1,f2,f3,f4;f1=(fn1<=fn2)?fn1:fn2;f3=(fn1>fn2)?fn1:fn2;f2=(fn3<=fn4)?fn3:fn4;f4=(fn1>fn2)?fn1:fn2;if(f1<=f2)if(f3<=f2)return f3;else return f2;else if(f4<=f1)return f4; else return f1;void budeng(int f1,int f2,int fn1,int fn2,in
10、t fn3,int fn4,int Zerosign)/處理估價(jià)函數(shù)最小值唯一的時(shí)候if(f1=fn1)if(moveaction!='d'&&jingguo(c)move_up(c,Zerosign);moveaction='u'elseif(f2=fn2)move_right(c,Zerosign);moveaction='r'if(f2=fn3)move_left(c,Zerosign);moveaction='l'if(f2=fn4)move_down(c,Zerosign);moveaction='
11、;d'if(f1=fn2)if(moveaction!='l'&&jingguo(c)move_right(c,Zerosign);moveaction='r'elseif(f2=fn3)move_left(c,Zerosign);moveaction='l'if(f2=fn4)move_down(c,Zerosign);moveaction='d'if(f2=fn1)move_up(c,Zerosign);moveaction='u'if(f1=fn3)if(moveaction!=
12、9;r'&&jingguo(c)move_left(c,Zerosign);moveaction='l'elseif(f2=fn1)move_up(c,Zerosign);moveaction='u'if(f2=fn2)move_right(c,Zerosign);moveaction='r'if(f2=fn4)move_down(c,Zerosign);moveaction='d'if(f1=fn4)if(moveaction!='u'&&jingguo(c)move_do
13、wn(c,Zerosign);moveaction='d'elseif(f2=fn2)move_right(c,Zerosign);moveaction='r'if(f2=fn3)move_left(c,Zerosign);moveaction='l'if(f2=fn1)move_up(c,Zerosign);moveaction='u'int ceshi(int k9)/測試估價(jià)函數(shù)int fn1=100,fn2=100,fn3=100,fn4=100,f1,Zerosign;for(int i=0;i<9;i+)if(0
14、=ki)Zerosign=i;break;if(Zerosign!=0&&Zerosign!=1&&Zerosign!=2&&moveaction!='d')fn1=move_up(c,Zerosign);if(Zerosign!=2&&Zerosign!=5&&Zerosign!=8&&moveaction!='l')fn2=move_right(c,Zerosign);if(Zerosign!=0&&Zerosign!=3&&Zer
15、osign!=6&&moveaction!='r')fn3=move_left(c,Zerosign);if(Zerosign!=6&&Zerosign!=7&&Zerosign!=8&&moveaction!='u')fn4=move_down(c,Zerosign);f1=zuixiao(fn1,fn2,fn3,fn4);return f1;void move(int c9)/確定移動(dòng)方向int fn1=100,fn2=100,fn3=100,fn4=100,f1,f2,Zerosign;for
16、(int i=0;i<9;i+)if(0=ci)Zerosign=i;break;if(Zerosign!=0&&Zerosign!=1&&Zerosign!=2&&moveaction!='d')fn1=move_up(c,Zerosign);if(Zerosign!=2&&Zerosign!=5&&Zerosign!=8&&moveaction!='l')fn2=move_right(c,Zerosign);if(Zerosign!=0&&Z
17、erosign!=3&&Zerosign!=6&&moveaction!='r')fn3=move_left(c,Zerosign);if(Zerosign!=6&&Zerosign!=7&&Zerosign!=8&&moveaction!='u')fn4=move_down(c,Zerosign);f1=zuixiao(fn1,fn2,fn3,fn4);f2=cixiao(fn1,fn2,fn3,fn4);if(f1=f2)if(fn1=fn2&&fn1=f1)mo
18、ve_up(c,Zerosign);for(i=0;i<9;i+)ei=ci;move_right(c,Zerosign);for(i=0;i<9;i+)fi=ci;if(ceshi(e)<ceshi(f)&&jingguo(e)move_up(c,Zerosign);moveaction='u'else move_right(c,Zerosign);moveaction='r'if(fn1=fn3&&fn1=f1)move_up(c,Zerosign);for(i=0;i<9;i+)ei=ci;move_
19、left(c,Zerosign);for(i=0;i<9;i+)fi=ci;if(ceshi(e)<ceshi(f)&&jingguo(e)move_up(c,Zerosign);moveaction='u'else move_left(c,Zerosign);moveaction='l'if(fn1=fn4&&fn1=f1)move_up(c,Zerosign);for(i=0;i<9;i+)ei=ci;move_down(c,Zerosign);for(i=0;i<9;i+)fi=ci;if(ceshi
20、(e)<ceshi(f)&&jingguo(e)move_up(c,Zerosign);moveaction='u'else move_down(c,Zerosign);moveaction='d'if(fn2=fn3&&fn2=f1)move_right(c,Zerosign);for(i=0;i<9;i+)ei=ci;move_left(c,Zerosign);for(i=0;i<9;i+)fi=ci;if(ceshi(e)<ceshi(f)&&jingguo(e)move_right(
21、c,Zerosign);moveaction='r'else move_left(c,Zerosign);moveaction='l'if(fn2=fn4&&fn2=f1)move_right(c,Zerosign);for(i=0;i<9;i+)ei=ci;move_down(c,Zerosign);for(i=0;i<9;i+)fi=ci;if(ceshi(e)<ceshi(f)&&jingguo(e)move_right(c,Zerosign);moveaction='r'else move
22、_down(c,Zerosign);moveaction='d'if(fn3=fn4&&fn3=f1)move_left(c,Zerosign);for(i=0;i<9;i+)ei=ci;move_down(c,Zerosign);for(i=0;i<9;i+)fi=ci;if(ceshi(e)<ceshi(f)&&jingguo(e)move_left(c,Zerosign);moveaction='l' else move_down(c,Zerosign);moveaction='d'else
23、 budeng(f1,f2,fn1,fn2,fn3,fn4,Zerosign);int duibi(int c9) /與目標(biāo)節(jié)點(diǎn)比較for(int i=0;i<9;i+)if(ci!=finali)break;if(i>=9)return 1;else return 0;int cunzaixing(int c9) /得出初始化節(jié)點(diǎn)是否存在路徑到目標(biāo)節(jié)點(diǎn)int nixu=0,nixu1=0,i,j;for( j=0;j<9;j+)for(int i=j+1;i<9;i+)if(finalj>finali&&finalj!=0&&fi
24、nali!=0)nixu+;for(j=0;j<9;j+)for( i=j+1;i<9;i+)if(cj>ci&&cj!=0&&ci!=0)nixu1+; if(nixu%2)-(nixu1%2)=0) return 1;else return 0;void main()/主函數(shù)int sd=1;printf("請輸入初始結(jié)點(diǎn)如(2 8 3 1 6 4 7 0 5)以空格隔開的九個(gè)0到9之間的不重復(fù)數(shù): n");for(int i=0;i<9;i+)scanf("%d",&bi); ci=b
25、i;printf("您輸入的初始矩陣為:n");show(c);deep-;if(cunzaixing(c)=0)printf("此矩陣不存在路徑至目標(biāo)矩陣!n");elsewhile(!duibi(c)&&deep<100)move(c);printf("第%d步移動(dòng)后的矩陣為:n",sd+);show(c);for(int i=0;i<9;i+)bi=ci;實(shí)驗(yàn)二 王浩算法的實(shí)現(xiàn)1. 實(shí)驗(yàn)內(nèi)容:實(shí)現(xiàn)命題邏輯框架內(nèi)的王浩算法。 將命題邏輯中的王浩算法推廣至下述命題語言的情形之下: 命題變量符號:, 邏輯連
26、接符:, 間隔符:, 在上述中所定義的命題語言中實(shí)現(xiàn)王浩算法。2. 實(shí)驗(yàn)?zāi)康氖炀氄莆彰}邏輯中的王浩算法。3. 實(shí)驗(yàn)要求 實(shí)驗(yàn)題目必須由個(gè)人獨(dú)立完成,允許自行參考相關(guān)文獻(xiàn)資料,但嚴(yán)禁同學(xué)間相互拷貝和抄襲程序以及文檔資料。實(shí)驗(yàn)結(jié)束后一周內(nèi)上交實(shí)驗(yàn)報(bào)告和實(shí)驗(yàn)文檔資料。 提交的文檔資料包括設(shè)計(jì)文檔和程序源代碼。設(shè)計(jì)文檔和程序源代碼以書面文檔方式提供(用紙打?。?;并提交電子文檔備查。四數(shù)據(jù)結(jié)構(gòu)給定公式,例如:(p1->(q1->r1)->(p1->q1)->(p1->r1)函數(shù)inite主要作用是負(fù)責(zé)將符號初始化成樹的結(jié)構(gòu)。函數(shù)clone復(fù)制一棵完全相同的符號樹。函
27、數(shù)restruct查找所有&,|, <->等符號,并將其拆分成新形式:!,->符號。函數(shù)searching王浩算法的主要函數(shù)。函數(shù)show和output:顯示符號串和推理過程。五實(shí)驗(yàn)結(jié)果公式正確 六實(shí)驗(yàn)總結(jié)通過本次實(shí)驗(yàn),使我更深入的理解了啟發(fā)式搜索的原理以及實(shí)現(xiàn),對于其優(yōu)越性有一定認(rèn)識,加深了對語法分析以及邏輯公式理解,同時(shí)熟練掌握了對樹的操作。在編程實(shí)現(xiàn)過程中出現(xiàn)過不少問題,通過一次次調(diào)試得以解決,并一定程度上提高了我的編程能力,而且讓我對人工智能這一課程有了更直接的認(rèn)知。王浩算法源代碼清單:#include<stdio.h>#include<st
28、dlib.h>#include<string.h>#define MAX_L 5int i=0;int stepcount=1;enum typeand,or,detrusion,equal,level,variable;struct nodechar *s;type kind;int polar;node *next;node *child;int start;struct stepstep *child;step *brother;node *lhead;node *rhead;int count;char name30;int inite(char *s,node *h
29、ead)int len=strlen(s);int j=0,polar=1;node *now=NULL;node *last=NULL;if(s=NULL)return 0;last=head;while(i<len)if(si='|')if(!(si+1<='Z'&&si+1>='A'|si+1<='z'&&si+1>='a')&&si+1!='1'&&si+1!='0'&&am
30、p;si+1!='('&&si+1!='!'|i=0)return 0;now=(node*)malloc(sizeof(node);now->kind=or;now->s=NULL;now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;if(last->kind=level&&last->child=NULL)last->child=now;elselast->next=now;last=now;i+;
31、else if(si='&')if(!(si+1<='Z'&&si+1>='A'|si+1<='z'&&si+1>='a')&&si+1!='1'&&si+1!='0'&&si+1!='('&&si+1!='!'|i=0)return 0;now=(node*)malloc(sizeof(node);now->kind=
32、and;now->s=NULL;now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;if(last->kind=level&&last->child=NULL)last->child=now;elselast->next=now;last=now;i+;else if(si='!')if(!(si+1<='Z'&&si+1>='A'|si+1<='z'&
33、;&si+1>='a')&&si+1!='1'&&si+1!='0'&&si+1!='('&&si+1!='!')return 0;polar=1-polar;i+;else if(si='-')if(si+1!='>'|(si+2!='!'&&si+2!='('&&!(si+2<='Z'&&si+2
34、>='A'|si+2<='z'&&si+2>='a')|i=0)return 0;now=(node*)malloc(sizeof(node);now->kind=detrusion;now->s=NULL;now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;if(last->kind=level&&last->child=NULL)last->child=now;elsel
35、ast->next=now;last=now;i=i+2;else if(si='<')if(si+1!='-'|si+2!='>')|(si+3!='!'&&si+3!='('&&!(si+3<='Z'&&si+3>='A'|si+3<='z'&&si+3>='a')|i=0)&&si+3!='1'&&am
36、p;si+3!='0')return 0;now=(node*)malloc(sizeof(node);now->kind=equal;now->s=NULL;now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;if(last->kind=level&&last->child=NULL)last->child=now;elselast->next=now;last=now;i=i+3;else if(si<='Z'
37、;&&si>='A'|si<='z'&&si>='a')now=(node*)malloc(sizeof(node);now->kind=variable;now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;now->s=(char*)malloc(MAX_L*sizeof(char);if(last->kind=level&&last->child=NULL)la
38、st->child=now;elselast->next=now;last=now;j=0;while(si<='Z'&&si>='A'|si<='z'&&si>='a')|(si<='9'&&si>='0')(now->s)j=si;i+;j+;if(si!='|'&&si!='&'&&si!='-'&
39、&si!='<'&&si!='0'&&si!=')')return 0;(now->s)j='0'polar=1;else if(si='1'|si='0')if(si+1!='<'&&si+1!='-'&&si+1!='&'&&si+1!='|'&&si+1!=')'&&si
40、+1!='0')return 0;now=(node*)malloc(sizeof(node);now->kind=equal;now->s=(char*)malloc(2*sizeof(char);(now->s)0=si;(now->s)1='0'now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;if(last->kind=level&&last->child=NULL)last->child=now;el
41、selast->next=now;last=now;i+;else if(si='(')if(!(si+1<='Z'&&si+1>='A'|si+1<='z'&&si+1>='a')&&si+1!='1'&&si+1!='0'&&si+1!='!'&&si+1!='(')return 0;now=(node*)malloc(si
42、zeof(node);now->kind=level;now->s=NULL;now->next=NULL;now->child=NULL;now->polar=polar;now->start=0;if(last->kind=level&&last->child=NULL)last->child=now;elselast->next=now;last=now;i+;polar=1;if(!inite(s,last)return 0;else if(si=')')if(si+1!='P'
43、&&si+1!='1'&&si+1!='0'&&si+1!='-'&&si+1!='<'&&si+1!='&'&&si+1!='|'&&si+1!='0'&&si+1!=')')return 0;i+;return 1;else return 0;return 1;node* clone(node *parent)node *s
44、on=NULL;if(parent=NULL)return NULL;son=(node*)malloc(sizeof(node);son->kind=parent->kind;son->polar=parent->polar;son->s=parent->s;son->start=parent->start;if(parent->next!=NULL)son->next=clone(parent->next);else son->next=NULL;if(parent->child!=NULL)son->ch
45、ild=clone(parent->child);elseson->child=NULL;return son;void remove(node *head)node *now=NULL;now=head;if(now=NULL)return;if(now->kind=level&&now->child->kind=variable&&now->child->next=NULL)now->polar=(now->child->polar=now->polar);now->child->
46、polar=1;while(now->kind=level&&now->child->kind=level&&now->child->next=NULL)now->polar=(now->polar=now->child->polar);now->child=now->child->child;if(now->next!=NULL)remove(now->next);if(now->child!=NULL)remove(now->child);void restruc
47、t(node* head)node *now=NULL;node *last=NULL;node *newone=NULL,*newtwo=NULL,*newthree=NULL,*newfour=NULL,*newnow=NULL;int order=1;while(order<=4)last=head;now=last->child;while(now!=NULL)if(now->kind=variable|now->kind=level)&&order=1)if(now->next!=NULL&&now->next-&g
48、t;kind=and)newone=(node*)malloc(sizeof(node);newone->child=NULL;newone->kind=level;newone->next=NULL;newone->polar=0;newone->s=NULL;newone->start=0;if(last->kind=level)last->child=newone;elselast->next=newone;newone->next=now->next->next->next;newone->child=
49、now;now->next->next->polar=1-now->next->next->polar;now->next->kind=detrusion;now->next->next->next=NULL;now=newone;elselast=now;now=now->next;else if(now->kind=variable|now->kind=level)&&order=2)if(now->next!=NULL&&now->next->kind=o
50、r) newone=(node*)malloc(sizeof(node);newone->child=NULL;newone->kind=level;newone->next=NULL;newone->polar=1;newone->s=NULL;newone->start=0;if(last->kind=level)last->child=newone;elselast->next=newone;newone->next=now->next->next->next;newone->child=now;now-
51、>polar=1-now->polar;now->next->kind=detrusion;now->next->next->next=NULL;now=newone;elselast=now;now=now->next;else if(now->kind=variable|now->kind=level)&&order=3)if(now->next!=NULL&&now->next->kind=equal)newone=(node*)malloc(sizeof(node);newon
52、e->child=NULL;newone->kind=level;newone->next=NULL;newone->polar=0;newone->s=NULL;newone->start=0;newtwo=(node*)malloc(sizeof(node);newtwo->child=NULL;newtwo->kind=level;newtwo->next=NULL;newtwo->polar=1;newtwo->s=NULL;newtwo->start=0;newthree=(node*)malloc(sizeof
53、(node);newthree->child=NULL;newthree->kind=detrusion;newthree->next=NULL;newthree->polar=1;newthree->s=NULL;newthree->start=0;newfour=(node*)malloc(sizeof(node);newfour->child=NULL;newfour->kind=level;newfour->next=NULL;newfour->polar=0;newfour->s=NULL;newfour->st
54、art=0;if(last->kind=level)last->child=newone; elselast->next=newone;newone->next=now->next->next->next;newone->child=newtwo;now->next->kind=detrusion;newtwo->child=now;now->next->next->next=NULL;newtwo->next=newthree;newthree->next=newfour;newfour->
55、next=NULL;newnow=clone(now);newnow->next->kind=detrusion;newfour->child=newnow->next->next;newnow->next->next->next=newnow->next;newnow->next->next=newnow;newnow->next=NULL;now=newone;elselast=now;now=now->next;else if(now->kind=level&&order=4)restru
56、ct(now);last=now;now=now->next;elselast=now;now=now->next;order+;void show(node *head)node *now=NULL;now=head;while(now!=NULL)if(now->kind=level)if(now->polar=0)printf("!");if(now->start!=1|(now->polar=0&&now->child->next!=NULL)printf("(");show(now->child);if(now->start!=1|(now->polar=0&&now->child->next!=NULL)printf(")");now=now->next;if(now!=NULL&
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 房屋中介公司雇傭合同
- 個(gè)人授信額度借款合同
- 個(gè)人房屋出租協(xié)議書
- 鋁合金方管施工方案
- 懸挑翼緣板施工方案
- 廠房照明施工方案
- 瓷磚干掛施工方案
- 海西輕鋼別墅施工方案
- 沈陽地源熱泵井施工方案
- 河南省平頂山市汝州市2024-2025學(xué)年八年級上學(xué)期期末生物試題(原卷版+解析版)
- 廣東外語外貿(mào)大學(xué)會計(jì)專碩復(fù)試
- 行政處罰案件集體討論審理記錄
- 變電站綜合自動(dòng)化
- 德語現(xiàn)代主義文學(xué)-浙江大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年
- 2022年安徽省公務(wù)員錄用考試《行測》真題及答案
- 2023年高中音樂課件大宅門-電視劇《大宅門》主題歌
- 國際貿(mào)易地理全套課件
- 內(nèi)科學(xué)支氣管擴(kuò)張癥(課件)
- 部編人教版五年級道德與法治下冊全冊完整課件ppt
- RB/T 115-2014能源管理體系石油化工企業(yè)認(rèn)證要求
- GB/T 32512-2016光伏發(fā)電站防雷技術(shù)要求
評論
0/150
提交評論