add a function generateLongExpr in stackApp.c(h). Add a comprehensive conclusion on calc infix & catalan.

This commit is contained in:
Shine wOng
2019-12-10 16:36:31 +08:00
parent ac443f791a
commit 59df68904c
4 changed files with 116 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ void test_paren();
void test_evaluate();
void test_toPostfix();
int stackApp_test_main(){
int main(){
cout << "Running tests......" << endl;
test_convert();
test_paren();
@@ -38,6 +38,12 @@ void test_paren(){
void test_evaluate(){
assert(evaluate("2*5+(3+4-2*7)/2") == 6.5);
assert(evaluate("(0!+ 1) * 2 ^ (3!+ 4) - (5!- 67 - (8 + 9))") == 2012);
char* expr = generateLongExpr(1024);
//cout << expr << endl;
cout << evaluate(expr) << endl;
free(expr);
//cout << evaluate("1+2*3^(1+2*3)") << endl;;
//cout << evaluate("1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1+2*3^(1)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))") << endl;
}
void test_toPostfix(){