#include<stdio.h>
#include "arith_expr.h"
//char * str = "2+3*4+6";
//char * str = "2+3+6";
//char * str = "2.1+3+6";
//char * str = "2.1+3.0*2";
//char * str = "(2+3.1)*4";
char * str = "2+(3.1-(4-6))";
struct NUM * result;
void output()
{
printf("output:/n");
if (result->type == 0)
printf("%4d/n",result->value.ivalue);
else
printf("%4.2f/n",result->value.fvalue);
};
int main()
{
init(stdout,str);
printf("expression is :/n%s/n",str);
result = compute();
if (result==NULL)
printf("The expression is error/n");
else
output();
return(1);
};
#include "arith_expr.h"
//char * str = "2+3*4+6";
//char * str = "2+3+6";
//char * str = "2.1+3+6";
//char * str = "2.1+3.0*2";
//char * str = "(2+3.1)*4";
char * str = "2+(3.1-(4-6))";
struct NUM * result;
void output()
{
printf("output:/n");
if (result->type == 0)
printf("%4d/n",result->value.ivalue);
else
printf("%4.2f/n",result->value.fvalue);
};
int main()
{
init(stdout,str);
printf("expression is :/n%s/n",str);
result = compute();
if (result==NULL)
printf("The expression is error/n");
else
output();
return(1);
};