Êý¾Ý½á¹¹Ï°Ì⼯´ð°¸½âÎöÇ廪´óѧ°æ

}

}

) ) ) )

g[CurPos¡¢x+1][CurPos¡¢y]¡¢Color==OldColor

Push(s,g[CurPos¡¢x+1][CurPos¡¢y]); !g[CurPos¡¢x-1][CurPos¡¢y]¡¢Visited && g[CurPos¡¢x-1][CurPos¡¢y]¡¢Color==OldColor Push(s,g[CurPos¡¢x-1][CurPos¡¢y]); !g[CurPos¡¢x][CurPos¡¢y+1]¡¢Visited && g[CurPos¡¢x][CurPos¡¢y+1]¡¢Color==OldColor Push(s,g[CurPos¡¢x][CurPos¡¢y+1]); !g[CurPos¡¢x][CurPos¡¢y-1]¡¢Visited && g[CurPos¡¢x][CurPos¡¢y-1]¡¢Color==OldColor Push(s,g[CurPos¡¢x][CurPos¡¢y-1]);

if(CurPos¡¢x>0 &&

if(CurPos¡¢y

if(CurPos¡¢y>0 &&

void CreateGDS(ElemType g[M][N]) { }

void ShowGraphArray(ElemType g[M][N]) {

int i,j;

for(i=0;i

for(j=0;j

cout<

for(j=0;j

for(j=2;j<4;j++)

g[i][j]¡¢Color=3; g[i][j]¡¢seat¡¢x=i; g[i][j]¡¢seat¡¢y=j; g[i][j]¡¢Visited=0; g[i][j]¡¢Color=0;

for(i=2;i<5;i++)

for(i=5;i

for(j=3;j<6;j++)

g[i][j]¡¢Color=3;

}

}

3¡¢21 ¼ÙÉè±í´ïʽÓе¥×Öĸ±äÁ¿ÓëË«Ä¿ËÄÔòÔËËã·û¹¹³É¡£ÊÔдһ¸öËã·¨£¬½«Ò»¸öͨ³£ÊéдÐÎʽÇÒÊéдÕýÈ·µÃ±í´ïʽת»»ÎªÄ沨À¼±í´ïʽ¡£¹Ý÷¯¹~¾—¼÷À»½g¡£ ½â£º

// ÊäÈëµÃ±í´ïʽ´®±ØÐëΪ#¡¢¡¢¡¢#¸ñʽ

void InversePolandExpression(char Buffer[]) { }

Status IsOpertor(char c) {

char *p=\while(*p){

if(*p==c) Stack s; InitStack(s); int i=0,j=0; ElemType e; Push(s,Buffer[i]); i++;

while(Buffer[i]!='#'){ }

while(!StackEmpty(s)){ }

Pop(s,e); Buffer[j]=e; j++;

if(!IsOperator(Buffer[i])){ // ¾ÍÊDzÙ×÷Êý } else{ }

// ¾ÍÊDzÙ×÷·û GetTop(s,e);

if(Prior(e,Buffer[i])){// µ±Õ»¶¥ÓÅÏÈȨ¸ßÓÚµ±Ç°ÐòÁÐʱ£¬ÍËÕ» } else{ }

Push(s,Buffer[i]); i++; Pop(s,e); Buffer[j]=e; j++;

Buffer[j]=Buffer[i]; i++; j++;

}

}

return TRUE;

p++;

return FALSE;

Status Prior(char c1,char c2) { }

3¡¢22 ÈçÌâ3¡¢21µÃ¼ÙÉèÌõ¼þ£¬ÊÔдһ¸öËã·¨£¬¶ÔÒÔÄ沨À¼Ê½±íʾµÃ±í´ïʽÇóÖµ¡£

½â£º

char CalVal_InverPoland(char Buffer[]) { }

char Cal(char c1,char op,char c2) {

int x,x1,x2; Stack Opnd; InitStack(Opnd); int i=0; char c; ElemType e1,e2; while(Buffer[i]!='#'){ }

return c;

if(!IsOperator(Buffer[i])){ } else{ } i++;

Pop(Opnd,e2); Pop(Opnd,e1);

c=Cal(e1,Buffer[i],e2); Push(Opnd,c); Push(Opnd,Buffer[i]);

char ch[]=\int i=0,j=0;

while(ch[i] && ch[i]!=c1) i++;

if(i==2) i--; // ¼ÓÓë¼õ¿ÉÈÏΪ¾ÍÊÇͬ¼¶±ðµÃÔËËã·û if(i==4) i--; // ³ËÓë³ý¿ÉÈÏΪ¾ÍÊÇͬ¼¶±ðµÃÔËËã·û while(ch[j] && ch[j]!=c2) j++; if(j==2) j--; if(j==4) j--;

if(i>=j) return TRUE; else return FALSE;

}

char ch[10]; ch[0]=c1; ch[1]='\\0'; x1=atoi(ch); ch[0]=c2; ch[1]='\\0'; x2=atoi(ch); switch(op){ case '+': }

itoa(x,ch,10); return ch[0];

x=x1+x2; break; x=x1-x2; break; x=x1*x2; break; x=x1/x2; break; break;

case '-':

case '*':

case '/':

default:

3¡¢23 ÈçÌâ3¡¢21µÃ¼ÙÉèÌõ¼þ£¬ÊÔдһ¸öËã·¨£¬Åжϸø¶¨µÃ·Ç¿Õºó׺±í´ïʽ¾ÍÊÇ·ñΪÕýÈ·µÃÄ沨À¼±í´ïʽ£¬Èç¹û¾ÍÊÇ£¬Ôò½«Ëüת»¯Îª²¨À¼Ê½¡£Ã»èŽ½°å^ŒÀóE²ô¡£ ½â£º

#include #include #include

#include \¡¢h\typedef char ARRAY[30]; typedef ARRAY ElemType; typedef struct NodeType{

ElemType data; NodeType *next;

}NodeType,*LinkType; typedef struct{

LinkType top; int size;

}Stack;

void InitStack(Stack &s);

Status Push(Stack &s,ElemType e); Status Pop(Stack &s,ElemType e); Status IsOperator(char c); Status StackEmpty(Stack s); Status InvToFroPoland(char a[]); int main() { }

Status InvToFroPoland(char a[]) {

Stack s; InitStack(s); int i=0; ElemType ch; ElemType c1; ElemType c2; while(a[i]!='#'){

if(!IsOperator(a[i])){ } else{

ch[0]=a[i]; ch[1]='\\0'; if(!StackEmpty(s)){ }

else return FALSE;

Pop(s,c2);

if(!StackEmpty(s)){ }

else return FALSE;

Pop(s,c1); strcat(ch,c1); strcat(ch,c2); Push(s,ch);

if(a[i]>='0' && a[i]<='9'){ }

else return FALSE;

ch[0]=a[i]; Push(s,ch);

ch[1]='\\0';

char a[30];

cout<<\ÇëÊäÈëÄ沨À¼ËãÊõ±í´ïʽ×Ö·ûÐòÁУº\cin>>a;

if(InvToFroPoland(a)) cout<

else cout<<\ÊäÈëÄ沨À¼ËãÊõ±í´ïʽ×Ö·ûÐòÁдíÎó!\return 0;

ÁªÏµ¿Í·þ£º779662525#qq.com(#Ì滻Ϊ@) ËÕICP±¸20003344ºÅ-4