上一页 1 ··· 8 9 10 11 12
摘要: 没注意看题,一开始把元素类型弄成char了,搞了好久都AC不了,换成int一次就AC了。 题意: 即用两个栈来模拟队列,使两个栈协作实现队列的功能。 思路: 1.第一个栈为输入栈,第二个栈为输出栈,输入栈比输出栈要小。 2.栈满条件:输入栈满了而输出栈不为空,说明栈满了,因为输出栈还有元素的话,输入 阅读全文
posted @ 2020-03-06 16:54 幻想Elapse 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 参考:https://blog.csdn.net/qq_36254699/article/details/78824351 前缀表达式求值方法: 先将表达式入栈a,将栈a元素逐个出栈,如果是数字,直接入栈b,如果是操作符x,则b出栈2次,用t1接收第一个数,t2接收第二个数,再将t2 x t1的计算 阅读全文
posted @ 2020-03-05 23:08 幻想Elapse 阅读(722) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://pintia.cn/problem-sets/15/problems/827 参考:https://blog.csdn.net/SiKongPop/article/details/77972879#comments(内附数个测试样例) 题意: 将输入中缀表达式转换为后缀表达 阅读全文
posted @ 2020-03-02 22:12 幻想Elapse 阅读(592) 评论(0) 推荐(0) 编辑
摘要: 不知道题目说的尽可能高效的算法是啥,我就只按我会的来了,无语…… 有时候最后两个测试点会超时,再提交一次又能AC了。 1 #include <iostream> 2 #include <string> 3 #include <cstring> 4 using namespace std; 5 6 s 阅读全文
posted @ 2020-03-01 16:29 幻想Elapse 阅读(549) 评论(0) 推荐(0) 编辑
摘要: 挺简单的用队列求解的一题,难度不大。 输出格式要注意。 1 #include <iostream> 2 #include <string> 3 #include <cstring> 4 using namespace std; 5 6 class queue_ 7 { 8 public: 9 que 阅读全文
posted @ 2020-03-01 14:41 幻想Elapse 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 参考: https://blog.csdn.net/computerme/article/details/18080511的和https://zhuanlan.zhihu.com/p/36085324的。 简单说一下我理解到的方法吧 第一步是判断输入的n是奇数还是偶数,若为奇数,则按顺时针以ACB的 阅读全文
posted @ 2020-03-01 11:22 幻想Elapse 阅读(917) 评论(0) 推荐(0) 编辑
摘要: 唯一的坑可能就是0多项式的时候的输出格式吧,是输出2个0,一开始没注意就写了一个0,死活没通过。 #include <iostream> #include <string> #include <cstring> using namespace std; int a1[10000] = {0}; in 阅读全文
posted @ 2020-03-01 10:28 幻想Elapse 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 这一题知识点与7-14基本上是一样的,都是用的散列。 AC的代码: //将QQ号的类型从数字型改为字符串型后,成功AC。 #include <iostream> #include <string> #include <cstring> using namespace std; long N; typ 阅读全文
posted @ 2020-03-01 10:24 幻想Elapse 阅读(974) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <string> #include <cstring> using namespace std; int max_ = 0;//每当count增加时,就判断此时增加后的count是不是最大,max_存储当前最大值 int f = 0;//标志 阅读全文
posted @ 2020-02-29 22:44 幻想Elapse 阅读(349) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12