
数据结构
alfredtofu
这个作者很懒,什么都没留下…
展开
-
二叉树三种遍历的非递归算法
<br />1.先序遍历非递归算法#define maxsize 100typedef struct{ Bitree Elem[maxsize]; int top;}SqStack;void PreOrderUnrec(Bitree t){ SqStack s; StackInit(s); p=t; while (p!=null || !StackEmpty(s)) { while (转载 2011-01-11 10:43:00 · 871 阅读 · 0 评论 -
低级计算器。。。
#include #include #include #include using namespace std;stack _operand;stack _operator;int isp(char c) { switch(c) { case '+': case '-': return 2; case '*': case '/': return 4; case '^': return 6; case '(':原创 2011-01-10 21:46:00 · 569 阅读 · 0 评论 -
sicily 1346 金明的预算方案 有依赖的背包问题
<br /><br />他还从因特网上查到了每件物品的价格(都是10元的整数倍)注意这句话就ok了。。之间没留意,结果TLE<br />#include <iostream>#include <cmath>#include <cstring>using namespace std;struct node { int v; //价格 int p; //重要度 int q; //所属主件的编号}data[61];int f[60][32001];原创 2011-02-20 11:32:00 · 2061 阅读 · 0 评论 -
uva 11121 - Base -2
<br />与底为整数稍有不同,就是当被除数小于0的时候,不能用自带的取模,因为要保证余数要大过0,这样只需要把除数加大。<br />#include <iostream>#include <cmath>#include <string>using namespace std;//#define TESTint main() {#ifdef TEST freopen("input.txt", "r", stdin);#endif int n; int res; i原创 2011-04-01 22:30:00 · 755 阅读 · 0 评论