0001 #include "rpn.h" 0002 #include "UniPrint/print.h" 0003 0004 /****************************************************************************************** 0005 * 输出运算符 0006 ******************************************************************************************/ 0007 void printChar ( char& p ) 0008 { ( '\0' == p ) ? printf ( "\\0 " ) : printf ( "%c ", p ); } 0009 0010 /****************************************************************************************** 0011 * 显示表达式处理进展 0012 ******************************************************************************************/ 0013 void displayProgress ( char* expr, char* pCh, Stack<float>& opndStk, Stack<char>& optrStk, char* rpn ) { 0014 system ( "cls" ); 0015 printf ( "\n" ); 0016 for ( char* p = expr; '\0' != *p; p++ ) printf ( " %c", *p ); printf ( " $\n" ); 0017 for ( char* p = expr; p < pCh; p++ ) printf ( " " ); 0018 if ( '\0' != * ( pCh - 1 ) ) 0019 { for ( char* p = pCh; '\0' != *p; p++ ) printf ( " %c", *p ); printf ( " $" ); } 0020 printf ( "\n" ); 0021 for ( char* p = expr; p < pCh; p++ ) printf ( "--" ); printf ( " ^\n\n" ); 0022 print ( optrStk ); printf ( "\n" ); 0023 print ( opndStk ); printf ( "\n" ); 0024 printf ( "RPN:\n %s\n\n", rpn ); //输出RPN 0025 getchar(); 0026 }