
C/C++
文章平均质量分 75
钱小伟
这个作者很懒,什么都没留下…
展开
-
简单计算器的C++实现
为了重温下list的用法,特地写了个简单的计算器,还有些问题,不过基本功能实现就不继续改进了。主要算法需要把我们习惯的中序换成后序,这样能够消除小括号,后序排序后就非常好处理了。另外输入时若有空格会出问题,不知道为什么,望C++大神能够解答。#include #include #include using namespace std;int operatorPriority(原创 2013-05-26 21:14:55 · 659 阅读 · 0 评论 -
给定两个排序后的链表L1\L2,仅用基本表操作求链表的交集和并集
算法还是比较简单的,由于链表已经排序,所以可以把复杂度控制在Θ(n1+n2)(n1\n2分别是链表L1\L2的长度)。比如算交集,如果L1.front()小于L2.front(),就L1.pop_front();如果L1.front()大于L2.front(),就开始在L2中循环,直到找到第一个大于或者等于L1.front()的元素,其中如果相等,则把这个数放入结果集中。说得不是很清楚,直接上原创 2013-05-26 21:06:52 · 2496 阅读 · 0 评论 -
Josephus problem solution
In computer science and mathematics, the Josephus Problem (or Josephus permutation) is a theoretical problem related to a certain counting-out game.There are people standing in a circle waitin原创 2013-05-30 16:43:24 · 594 阅读 · 0 评论