1. #ifndef__CALCULATOR_H__
2. #define__CALCULATOR_H__
3. #include<stdio.h>
4. #include<string.h>
5. #include<stdlib.h>
6. #include<windows.h>
7. #include<math.h>
8. typedeffloatDataType;
9. #defineMaxSize100
10.
11. typedefstruct
12. {
13. floatdata[MaxSize];
14. inttop;
15. }ComStack;
16. typedefstruct
17. {
18. floatdata[MaxSize];
19. inttop;
20. }Stack;
21. voidInitStack(Stack*s);
22. intGetTop(Stacks,DataType*z);
23. intPush(Stack*s,DataTypez);
24. intPop(Stack*s,DataType*z);
25. voidTransmitExpression(chara[],charb[]);
26. floatEvaluateExpression(charb[]);
27. intquit();
28. intmune();
29. intSimpleCalculator();
30. intExpressionCalculator();
31. #endif</pre><preclass="html"name="code"></pre><preclass="html"nam
e="code">————————函数部分——————</pre><preclass="html"name="code">
#include"calculator.h"
32. voidInitStack(Stack*s)
33. {
34. s->top=0;
35. }
36. intGetTop(Stacks,DataType*z)
37. {
38. if(s.top>0)
39. {
40. *z=s.data[s.top-1];
41. return1;
42. }