ÓÃÊéÉϵĴúÂëÆ´´ÕµÄ£¬»¹ÊǺÜÓгɾ͸еĹþ
Ö§³ÖµÄÔËËã·ûºÅÓÐ"+","-","*","/","(",")","#"¡£
Ö§³Ö20λÒÔÄÚÎÞ·ûºÅÕûÊý£¬µ±È»¿ÉÒÔºÜÈÝÒ׵ĸijÉÓзûºÅ»òÕßÊÇʵÐÍÊý
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define OPSETSIZE 7
//º¯Êý½á¹û״̬´úÂë
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
//StatusÊǺ¯ÊýµÄÀàÐÍ£¬ÆäÖµÊǺ¯Êý½á¹û״̬´úÂë
typedef int Status;
#define STACK_INIT_SIZE 1000 //´æ´¢¿Õ¼ä³õʼ·ÖÅäÁ¿
typedef struct{
char *base;
char *top;
int stacksize;
}StackChar;
typedef struct{
float *base;
float *top;
int stacksize;
}StackFloat;
unsigned char Prior[7][7] = { // ±í3.1 Ëã·û¼äµÄÓÅÏȹØϵ
'>','>','<','<','<','>','>',
'>','>','<','<','<','>','>',
'>','>','>','>','<','>','>',
'>','>','>','>','<','>','>',
'<','<','<','<','<','=',' ',
'>','>','>','>',' ','>','>',
'<','<','<','<','<',' ','='
};
float Operate(float a, unsigned char theta, float b);
char OPSET[OPSETSIZE]={'+' , '-' , '*' , '/' ,'(' , ')' , '#'};
Status In(char Test,char* TestOp);
char precede(char Aop, char Bop);
int atof(char* snum){
int l=strlen(snum),i=1,sum=snum[l-1]-'0';
l--;
while(l--){
i*=10;
sum+=(snum[l]-'0')*i;
}
return sum;
}
void InitStackChar(StackChar &S){
//¹¹ÔìÒ»¸ö¿ÕÕ»S
S.base=(char*)malloc(STACK_INIT_SIZE * sizeof(char));
if(!S.base) exit(OVERFLOW);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
}
void InitStackFloat(StackFloat &S){
//¹¹ÔìÒ»¸ö¿ÕÕ»S
S.base=(float*)malloc(STACK_INIT_SIZE * sizeof(float));
if(!S.base) exit(OVERFLOW);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
}
char GetTopChar(StackChar S){
//·µ»ØSµÄÕ»¶¥ÔªËØ
return