摘要
本文用C语言对算术表达式程序设计进行算法分析,第1种是简单的计算器算法,没有括号的算术表达式,没有考虑×、÷优先+、-的四则运算法则,只是按输入先后顺序进行运算。第2种没有括号的算术表达式,考虑×、÷优先+、-的四则运算法则进行运算。第3种有括号的算术表达式,也考虑了括号优先与×、÷优先+、-的四则运算法则。
Using the C language, this article attempts to conduct algorithmic analysis for the arithmetic expressions by dividing them into three categories. In the first category, the simple method of calculation, as typically employed by calculators,is utilized.Its arithmetic expressions do not allow the input of comma (,), nor the arithmetic rules of the priorities (× and ÷ above + and -). This method only allows the calculation to be carried out according lo the order of the input. In the second category, the arithmetic expressions do not include comma ( ,), but do allow the arithmetic calculating rules of priorities (× and ÷ above + and -). In the third category, the arithmetic expressions not only include comma (,), but also allow the arithmetic calculating rules of priorities (×and ÷ above + and-).
出处
《闽江学院学报》
2003年第2期1-4,12,共5页
Journal of Minjiang University
基金
国家教育部1 11-3项目"现代远程教育手段在高职高专教育领域中的应用研究与实践"。