登录
首页 » c » 堆栈计算器

堆栈计算器

于 2022-02-04 发布 文件大小:2.88 kB
0 97
下载积分: 2 下载次数: 1

代码说明:

该文件为简单的多元计算器,目前还不能算浮点数,即除法也不能用。其他功能都可以。数据大小最大为999999。编程思路:在严蔚敏的数据结构书上的栈的基础上,再稍加一些细节。       为了避免使用两种数据类型的栈,写两种Push,Pop等函数,   我采取运算符和运算操作数栈都是字符型的。出现的问题及解决思路:    1.将一个数据全部压入栈,是按字符读取的,就不用转换,但     弹出的时候要知道弹多少位,所以用了一个数组,就是记录操作数    的位数的。这样才可以帮助我们弹出正确的数据。        2.弹出的数据要计算,又如何处理?由于我们记录了操作数的位数了,就可以先把字符转化成十进制数字,然后乘权相加把数据得出,计算的结果又要变为字符,再一个个压入栈。        3.整型数据化为字符,这里我先判断数据的位数,然后把数据的各个位置的单个数字取出变为字符压进栈。同时弹出的数据所对    应的数组内容就要更新为0,新压入的数据位数同时也要按顺序存到数组里。就是这点,不细致的话,很容易搞错。        4.更新数组的问题,每压入一个数据后,就会在判断接着的字符的语句块里给数组赋值,同时将标识置为0,等待为当前符号过后要压入的数据计数。在判断符号优先级里的第三种情况,一下子弹出两个数,数组对应就要置后面的为0,然后教前面的那个重置,载入   新计算出来的数据的位数。退出时,i++,从而下一个数组元素可以接  收新的数据的位数。        5.针对4的问题,有一种特殊情况要考虑:就是当读入右括号的  时候,会执行:Flag[i]=flag;假如该句是设置第二个数据的数据位。        flag

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • LED
    LED显示屏的设计可以实现动态字体的左移右移上下移动等功能(LED display is designed to realize the right to move to the left and so on down the function of dynamic fonts)
    2015-03-31 08:54:31下载
    积分:1
  • Sams---CPP-Primer-Plus--4th-Edition
    C++ Primer Plus, Fourth Edition presents the ANSI C++ standard beginning with a discussion of the essential elements of C++ programming: loops, expressions, functions, and classes. It walks readers through the basics of object-oriented programming: classes, inheritance, templates, and exceptions, as well as the latest object-oriented programming techniques. C++ Primer Plus contains hundreds of sample programs. The friendly tone, concise programs, and end-of-chapter review exercises allow beginners to write their own programs immediately.
    2014-02-18 10:53:03下载
    积分:1
  • Hedit
    一个几好用十六进制方便打开PE覺得好用所以推一推它上载來(A few easy-to-use hexadecimal PE feel that open onto one easy to use so push it to upload to)
    2007-11-10 14:47:12下载
    积分:1
  • DES-disk-system
    以C++语言在微机上实现了美国数据加密标准DES。可随微机软盘任意路径下的任何文件,加密,加密文件可在软、硬盘任何目录下或在网络中传送;另一方面可对软、硬盘中的任何文件进行解密,解密后的文件除在末尾多出几个空格符外与原文件完全相同,绝不影响EXE文件,COM文件或数据库文件的使用。密钥有加密者在键盘输入8个字符。(In c++ language microcomputer to U.S. data encryption standard DES. With the computer floppy disk arbitrary path of any of the files, encryption, encrypt files can be in soft, hard disk any directory or in the network transmission On the other hand, soft, hard disk to the any classify documents, the decrypted file in the end in a few more the space appears with the original documents are all the same, never affect EXE file, COM file or database files use. Key there are JiaMiZhe in keyboard input 8 characters. )
    2011-12-28 22:14:57下载
    积分:1
  • cellular auto machine
    元胞自动机模型,用于模拟交通流,内容为文献,需要使用caj viewer打开(Cellular automata model for simulating traffic flow, says the literature, requires the use of caj viewer opens)
    2014-02-08 10:33:50下载
    积分:1
  • cc-yang
    最近在书上找的一个程序,可以对微分方程的解法使用(Themselves in line to see a square root to be evaluated on, you can refer to the following)
    2011-10-08 13:33:36下载
    积分:1
  • C# 简单好用的远程桌面代码
    资源描述C# 简单好用的远程桌面代码,经测试很好用。
    2022-06-03 01:46:39下载
    积分:1
  • 维特比算法
    详细介绍与分析了符合CSSDS编码标准的(7,1/2)卷积编码及其维特比译码算法的软件实现
    2022-03-14 08:47:14下载
    积分:1
  • sample_UART
    瑞萨RL78/G13UART串口通讯例程(Renesas RL78/G13UART serial communications routines)
    2020-12-18 15:19:10下载
    积分:1
  • balls_tracker-master
    balltracker with pimpong ball
    2015-02-11 22:33:42下载
    积分:1
  • 696516资源总数
  • 106668会员总数
  • 21今日下载