给定文件中的中缀表达式,从文件中读取它,将其转换为后缀,并显示后缀以输出 [英] given an infix expression in file read it from file convert it into postfix and display the postfix to output

查看:99
本文介绍了给定文件中的中缀表达式,从文件中读取它,将其转换为后缀,并显示后缀以输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标是将一个后缀写入后缀转换器.您的程序应为
能够处理输入中的加法,乘法,减法和除法运算符.它也应该能够处理(可能是嵌套的)输入表达式中的括号.

实施:

程序的输入将是命令行中提供的文件名,如下所示.
c:> yourprog.exe file.txt
文件中的每一行将是一个以中缀表示法表示的表达式.收到文件名后,您
应该从文件中读取每一行,将每个表达式转换为后缀,然后输出转换后的
表达到屏幕上.


意味着我们必须在文件中写入一些表达式,然后读取并转换为后缀并输出,
请至少在c

解决方案

您的程序应为的后缀中做一个简单的后缀.
这意味着您应该编写它.我们不提供订购解决方案,尤其是针对家庭作业的问题.使用您的知识和课程笔记为您自己编写.当您遇到特定问题时,我们会尽力为您提供帮助,但您应该做主要工作.


您可能会发现许多后缀转换器的中缀示例,仅龙书" [^ ].


The goal is to write an infix to postfix converter. Your program should be
able to handle addition, multiplication, subtraction and division operators in the input. It should also be able to handle (possibly nested) parentheses in the input expression.

Implementation:

The input to the program will a filename provided on the command line as follows.
c:> yourprog.exe file.txt
Each line in the file will be an expression in infix notation. Upon receiving the file name, you
should read each line from the file, convert each expression to postfix and output the converted
expression to screen.


meaning we have to write some expressions in the file and the read it and convert it into the postfix and output it,
Please atleast make a simple infix to postfix in c

解决方案

Your program should be ...

That means you are expected to write it. We do not provide solutions to order, particularly for homework questions. Use your knowledge and course notes to write this for yourself. When you have specific problems then we will try to help you, but you are expected to do the main body of work.


You may find many many examples of infix to postfix converters just Googling for[^].
However, if you are really interested in the argument, then I suggest you reading a good book on compiler construction, like, for instance, the "Dragon Book"[^].


这篇关于给定文件中的中缀表达式,从文件中读取它,将其转换为后缀,并显示后缀以输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆