算术表达式的求值问题很常见,现在根据课题要求输入一串四则运算表达式,由计算机求出表达式的运算结果。要求所输入的算术表达式以字符的序列的形式输的英语翻译

算术表达式的求值问题很常见,现在根据课题要求输入一串四则运算表达式,由

算术表达式的求值问题很常见,现在根据课题要求输入一串四则运算表达式,由计算机求出表达式的运算结果。要求所输入的算术表达式以字符的序列的形式输入语法正确的、不含变量的操作数的整数算术表达式。在计算机中,算术表达式由常量、变量、运算符和括号组成。由于不同的运算符具有不同的优先级,又要考虑括号,因此,算术表达式的求值不可能严格地从左到右进行。因而在程序设计时,借助栈实现。此时实验是把中缀表达式转化为后缀表达式然后进行输出的,然后继续进行后缀表达式的输出,这个过程为初始化两个栈:运算符栈s1和储存中间结果的栈s2;从左至右扫描中缀表达式;遇到操作数时,将其压s2;遇到运算符时,比较其与s1栈顶运算符的优先级:如果s1为空,或栈顶运算符为左括号“(”,则直接将此运算符入栈;否则,若优先级比栈顶运算符的高,也将运算符压入s1;否则,将s1栈顶的运算符弹出并压入到s2中,再次转到(4.1)与s1中新的栈顶运算符相比较;遇到括号时:如果是左括号“(”,则直接压入s1;如果是右括号“)”,则依次弹出s1栈顶的运算符,并压入s2,直到遇到左括号为止,此时将这一对括号丢弃;重复步骤2至5,直到表达式的最右边;将s1中剩余的运算符依次弹出并压入s2;依次弹出s2中的元素并输出。结果逆即为中缀表达式对应的后缀表达式 。继续扫描后缀表达式:如果是数字,则让其进栈;若为操作符,则从栈中取出两个操作数,先取出的作为右操作数,后取出的作为左操作数,然后进行该操作符的运算,并使其结果入栈。重复上述过程,直至表达式扫描完成。最终栈中只留一个元素,就是结果。
0/5000
源语言: -
目标语言: -
结果 (英语) 1: [复制]
复制成功!
The problem of evaluating arithmetic expressions is very common. Now input a string of four arithmetic expressions according to the requirements of the subject, and the computer will find the result of the expression. The input arithmetic expression is required to input a grammatically correct integer arithmetic expression without variable operands in the form of a sequence of characters. In computers, arithmetic expressions consist of constants, variables, operators, and parentheses. Since different operators have different precedences and parentheses must be considered, the evaluation of arithmetic expressions cannot be performed strictly from left to right. Therefore, when programming, it is realized with the help of the stack. At this time, the experiment converts the infix expression into a postfix expression and then outputs it, and then continues the output of the postfix expression. This process is to initialize two stacks: the operator stack s1 and the stack s2 for storing intermediate results; from the left Scan the infix expression to the right; when it encounters the operand, press it into s2; when it encounters the operator, compare it with the priority of the operator on the top of the s1 stack: if s1 is empty, or the operator on the top of the stack is a left parenthesis "(", directly push this operator onto the stack; otherwise, if the priority is higher than the operator on the top of the stack, the operator will also be pushed into s1; otherwise, the operator on the top of the s1 stack will be popped and pushed into s2 , Go to (4.1) again to compare with the new top operator in s1; when encountering parentheses: if it is a left parenthesis "(", then press s1 directly; if it is a right parenthesis ")", then pop s1 in turn The operator at the top of the stack, and push s2 until it encounters the left parenthesis, then discard the pair of parentheses; repeat steps 2 to 5 until the rightmost of the expression; pop the remaining operators in s1 one by one and Push s2; pop the elements in s2 in turn and output. The result is the inverse of the suffix expression corresponding to the infix expression. Continue scanning the suffix expression: if it is a number, let it be pushed onto the stack; if it is an operator, then Take out two operands from the stack, take the first operand as the right operand, and then take the left operand as the left operand, then perform the operation of the operator and push the result into the stack. Repeat the above process until the expression scan is completed. Finally. Only one element left in the stack is the result.
正在翻译中..
结果 (英语) 2:[复制]
复制成功!
The evaluation of arithmetic expression is very common, now according to the requirements of the subject, input a series of four operation expressions, and get the operation result of the expression by computer. The input arithmetic expression is required to input the integer arithmetic expression with correct syntax and no variable operands in the form of character sequence. In computer, arithmetic expression consists of constant, variable, operator and bracket. Because different operators have different priorities and brackets are considered, it is impossible to evaluate arithmetic expressions strictly from left to right. Therefore, in programming, it is realized by means of stack. In this case, the experiment is to convert infix expression into suffix expression and then output, and then continue to output suffix expression. This process is to initialize two stacks: operator stack S1 and stack S2 storing intermediate results; Scan infix expression from left to right; When the operands are encountered, they are pressed to S2; When encountering an operator, compare its priority with the top of stack operator of S1: if S1 is empty, or the top of stack operator is left bracket "("), put the operator on the stack directly; Otherwise, if the priority is higher than that of the top of stack operator, the operator will also be pushed into S1; Otherwise, the operator at the top of S1 stack will pop up and press into S2, and then go to (4.1) again to compare with the new operator at the top of S1 stack; When encountering brackets: if it is left bracket "("), press S1 directly; If it is "right bracket") ", pop up the operator at the top of S1 stack in turn, and press S2 until the left bracket is met. At this time, the pair of brackets will be discarded; Repeat steps 2 to 5 until the rightmost side of the expression; Pop up the remaining operators in S1 and press them into S2; Pop up the elements in S2 in turn and output. The result inverse is the suffix expression corresponding to infix expression. Continue to scan the suffix expression: if it is a number, let it stack; If it is an operator, two operands are taken from the stack. The first one is taken as the right operand, and the second one is taken as the left operand. Then the operation of the operator is carried out and the result is put on the stack. Repeat the above process until the expression scan is complete. In the end, only one element is left in the stack, which is the result.<br>
正在翻译中..
结果 (英语) 3:[复制]
复制成功!
The evaluation of arithmetic expressions is very common. Now, according to the requirements of the subject, a series of four arithmetic expressions are input, and the results of the expressions are obtained by the computer. The input arithmetic expression is required to input an integer arithmetic expression with correct syntax and no variables in the form of a sequence of characters. In computers, arithmetic expressions consist of constants, variables, operators and parentheses. Because different operators have different priorities, and parentheses should be considered, the evaluation of arithmetic expressions cannot be strictly carried out from left to right. Therefore, in programming, it is realized by stack. At this time, the experiment is to convert infix expression into suffix expression and then output it, and then continue to output suffix expression. This process is to initialize two stacks: operator stack s1 and stack s2 for storing intermediate results; Scan infix expressions from left to right; When an operand is encountered, it is pressed s2; When an operator is encountered, compare its priority with s1 stack top operator: if s1 is empty, or the stack top operator is left parenthesis "("), this operator will be directly put on the stack; Otherwise, if the priority is higher than that of the stack top operator, press the operator into s1; Otherwise, pop up the top operator of s1 and press it into s2, and go to (4.1) again to compare with the new top operator of s1; When parenthesis is encountered: if it is the left parenthesis "(",press S1 directly; If it is a right parenthesis ")", the operators on the top of s1 stack will pop up in turn, and s2 will be pressed in until the left parenthesis is encountered, at which time the pair of parentheses will be discarded; Repeat steps 2 to 5 until the rightmost part of the expression; Pop up the remaining operators in s1 in turn and press them into S2; The elements in s2 are popped up in turn and output. The result inverse is the suffix expression corresponding to the infix expression. Continue to scan suffix expression: if it is a number, let it stack; If it is an operator, two operands are taken out of the stack, the first one is taken as the right operand, and the second one is taken as the left operand, then the operator is operated and the result is put on the stack. Repeat the above process until the expression scan is completed. There is only one element left in the final stack, which is the result.
正在翻译中..
 
其它语言
本翻译工具支持: 世界语, 丹麦语, 乌克兰语, 乌兹别克语, 乌尔都语, 亚美尼亚语, 伊博语, 俄语, 保加利亚语, 信德语, 修纳语, 僧伽罗语, 克林贡语, 克罗地亚语, 冰岛语, 加利西亚语, 加泰罗尼亚语, 匈牙利语, 南非祖鲁语, 南非科萨语, 卡纳达语, 卢旺达语, 卢森堡语, 印地语, 印尼巽他语, 印尼爪哇语, 印尼语, 古吉拉特语, 吉尔吉斯语, 哈萨克语, 土库曼语, 土耳其语, 塔吉克语, 塞尔维亚语, 塞索托语, 夏威夷语, 奥利亚语, 威尔士语, 孟加拉语, 宿务语, 尼泊尔语, 巴斯克语, 布尔语(南非荷兰语), 希伯来语, 希腊语, 库尔德语, 弗里西语, 德语, 意大利语, 意第绪语, 拉丁语, 拉脱维亚语, 挪威语, 捷克语, 斯洛伐克语, 斯洛文尼亚语, 斯瓦希里语, 旁遮普语, 日语, 普什图语, 格鲁吉亚语, 毛利语, 法语, 波兰语, 波斯尼亚语, 波斯语, 泰卢固语, 泰米尔语, 泰语, 海地克里奥尔语, 爱尔兰语, 爱沙尼亚语, 瑞典语, 白俄罗斯语, 科西嘉语, 立陶宛语, 简体中文, 索马里语, 繁体中文, 约鲁巴语, 维吾尔语, 缅甸语, 罗马尼亚语, 老挝语, 自动识别, 芬兰语, 苏格兰盖尔语, 苗语, 英语, 荷兰语, 菲律宾语, 萨摩亚语, 葡萄牙语, 蒙古语, 西班牙语, 豪萨语, 越南语, 阿塞拜疆语, 阿姆哈拉语, 阿尔巴尼亚语, 阿拉伯语, 鞑靼语, 韩语, 马其顿语, 马尔加什语, 马拉地语, 马拉雅拉姆语, 马来语, 马耳他语, 高棉语, 齐切瓦语, 等语言的翻译.

Copyright ©2024 I Love Translation. All reserved.

E-mail: