人工智能实验王浩算法Word下载.docx

上传人:b****7 文档编号:22586674 上传时间:2023-02-04 格式:DOCX 页数:27 大小:49.94KB
下载 相关 举报
人工智能实验王浩算法Word下载.docx_第1页
第1页 / 共27页
人工智能实验王浩算法Word下载.docx_第2页
第2页 / 共27页
人工智能实验王浩算法Word下载.docx_第3页
第3页 / 共27页
人工智能实验王浩算法Word下载.docx_第4页
第4页 / 共27页
人工智能实验王浩算法Word下载.docx_第5页
第5页 / 共27页
点击查看更多>>
下载资源
资源描述

人工智能实验王浩算法Word下载.docx

《人工智能实验王浩算法Word下载.docx》由会员分享,可在线阅读,更多相关《人工智能实验王浩算法Word下载.docx(27页珍藏版)》请在冰豆网上搜索。

人工智能实验王浩算法Word下载.docx

structnode{

char*s;

typekind;

intpolar;

node*next;

node*child;

intstart;

structstep{

step*child;

step*brother;

node*lhead;

node*rhead;

intcount;

charname[30];

//初始化,输入表达式

intinite(char*s,node*head){

intlen=strlen(s);

intj=0,polar=1;

node*current=NULL;

node*last=NULL;

if(s==NULL)return0;

last=head;

while(i<

len){

if(s[i]=='

|'

){

if(!

(s[i+1]<

='

Z'

&

s[i+1]>

A'

||s[i+1]<

z'

a'

)&

s[i+1]!

1'

0'

('

!

'

||i==0)return0;

current=(node*)malloc(sizeof(node));

current->

kind=or;

s=NULL;

next=NULL;

child=NULL;

polar=polar;

start=0;

if(last->

kind==level&

last->

child==NULL){

last->

child=current;

}

else{

next=current;

last=current;

i++;

}

elseif(s[i]=='

current=(node*)malloc(sizeof(node));

current->

kind=and;

if(last->

last->

}

else{

last=current;

i++;

)return0;

polar=1-polar;

-'

if(s[i+1]!

>

||(s[i+2]!

s[i+2]!

(s[i+2]<

s[i+2]>

||s[i+2]<

))||i==0)return0;

kind=detrusion;

i=i+2;

<

if((s[i+1]!

||s[i+2]!

)||(s[i+3]!

s[i+3]!

(s[i+3]<

s[i+3]>

||s[i+3]<

)||i==0)&

kind=equal;

i=i+3;

elseif(s[i]<

s[i]>

||s[i]<

kind=variable;

s=(char*)malloc(MAX_L*sizeof(char));

j=0;

while((s[i]<

)||(s[i]<

9'

)){

(current->

s)[j]=s[i];

j++;

if(s[i]!

s[i]!

\0'

)'

(current->

s)[j]='

;

polar=1;

||s[i]=='

s=(char*)malloc(2*sizeof(char));

s)[0]=s[i];

s)[1]='

kind=level;

polar=1;

if(!

inite(s,last))return0;

P'

return1;

elsereturn0;

}

return1;

}

//复制函数

node*clone(node*parent){

node*son=NULL;

if(parent==NULL)returnNULL;

son=(node*)malloc(sizeof(node));

son->

kind=parent->

kind;

polar=parent->

polar;

s=parent->

s;

start=parent->

start;

if(parent->

next!

=NULL){

son->

next=clone(parent->

next);

else{

child!

child=clone(parent->

child);

returnson;

voidremove(node*head){

current=head;

if(current==NULL)return;

if(current->

current->

child->

kind==variable&

next==NULL){

current->

polar=(current->

polar==current->

polar);

polar=1;

while(current->

child=current->

child;

=NULL)remove(current->

voidrestruct(node*head){

node*newone=NULL,*newtwo=NULL,*newthree=NULL,*newfour=NULL,*newcurrent=NULL;

intorder=1;

while(order<

=4){

last=head;

current=last->

while(current!

if((current->

kind==variable||current->

kind==level)&

order==1){

if(current->

=NULL&

next->

kind==and){

newone=(node*)malloc(sizeof(node));

newone->

polar=0;

if(last->

kind==level){

last->

child=newone;

}

else{

next=newone;

next=current->

next;

current->

polar=1-current->

current=newone;

last=current;

current=current->

elseif((current->

order==2){

kind==or){

newone=(node*)malloc(sizeof(node));

order==3){

kind==equal){

newtwo=(node*)malloc(sizeof(node));

newtwo->

newthree=(node*)malloc(sizeof(node));

newthree->

newfour=(node*)malloc(sizeof(node));

newfour->

child=newtwo;

next=newthree;

next=newfour;

newcurrent=clone(current);

newcurrent->

child=newcurrent->

next=newcurrent->

next=newcurrent;

elseif(current->

order==4){

restruct(current);

current=current->

order++;

voidshow(node*head){

while(current!

if(current->

if(current->

polar==0)printf("

"

);

start!

=1||(current->

polar==0&

=NULL))printf("

("

show(current->

)"

current=current->

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 文学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1