- 论坛徽章:
- 0
|
请教高手一个问题,关于关系运算符处理!
既然有现成的,那就用现成的吧!不愿用可做个参考 orient c++类库
23. csp程序解释执行器
24. csp语句解释执行器
- #include <cline.h>;
- void TestCLine(char * run_line)
- {
- TLine line;
- TParaMgr mgr;
- int res;
- line.SetParaMgr(&mgr);
- line.Run_Line(run_line,&res);
- printf("res of %s is %d\n",run_line,res);
- };
- int main(int argc,char * argv[])
- {
- TLine line;
- TParaMgr mgr;
- float x=100,y=200;
- line.SetParaMgr(&mgr);
- mgr.PushPara("x",x);
- mgr.PushPara("y",200);
- line.Run_Line("x=100*sin(2)+y");
- line.Run_Line("x*100",&y);
- mgr.GetParaValue("x",&x);
- printf("now x is %f y is %f\n",x,y);
- TestCLine("1<2");
- TestCLine("1>;2");
- TestCLine("1==2");
- TestCLine("(1<=2)&&(2>;3)");
- TestCLine("(1<=2)||(2>;3)");
- getchar();
- return 1;
- }
- /*
- 输出结果:
- now x is 290.929749 y is 29092.974609
- res of 1<2 is 1
- res of 1>;2 is 0
- res of 1==2 is 0
- res of (1<=2)&&(2>;3) is 0
- res of (1<=2)||(2>;3) is 1
- */
复制代码 |
|