会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
i梦
博客园
首页
新随笔
联系
订阅
管理
1
2
下一页
2014年4月21日
srm617 div2
摘要: 1:求两个和数x,y,使得x+y = n。刚开始没看懂题目意思就开始敲。。。结果可想而知。再次细心读题才发现。果然要做题必须要先理解题意。(才得了207.52)bool is_prime(int x){ if(x == 2) return true; for(int i = 2; i solv...
阅读全文
posted @ 2014-04-21 22:57 i梦
阅读(159)
评论(0)
推荐(0)
2013年11月28日
(二)前缀,中缀,后缀表达式
摘要: 如何根据前缀表达式递归建立二叉树比如: * + 1 3 – 6 4a.读入下一个算术运算符或者数值,b.创建一个包含运算符或者数值的节点,c.如何是运算符 则递归创建跟运算符的操作数对应的子数 否则节点是叶子节点 struct Node{ ElemType data; Node *left; Node *right;};//创建二叉树的节点方法一:Node *buildTree(){ char ch = getchar(); //每次读取一个字符 Node *node; if(ch >= '0' && ch data = ch; node->left
阅读全文
posted @ 2013-11-28 18:54 i梦
阅读(150)
评论(0)
推荐(0)
(一)前缀,中缀,后缀表达式
摘要: 1.中缀表达式:Hdu 1237http://acm.hdu.edu.cn/showproblem.php?pid=1237对于表达式1 + 2 / 3 * 4 + 5主要思想是在表达式末尾加入”#”,在运算符栈中加”#”作为标志。----表达式 ---operand ---number1 + 2 / 3 * 4 + 5 # #i = 1 # 1I = 2 # + 1I = 3 # + 1 ,2I = 4 # + / 1 ,2I = 5 # + / 1 ,2 ,3I = 6 # + 1, 2/3 # + *I = 7 # + * 1, 2/3, 4I = 8 # + 1, 2/3*...
阅读全文
posted @ 2013-11-28 18:53 i梦
阅读(202)
评论(0)
推荐(0)
2013年11月12日
hdu 1237(中序表达式求值)
摘要: 简单计算器Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11091 Accepted Submission(s): 3607 Problem Description读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值。Input测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有0时输入结束,相应的结果不要输出。Output对每个测试用例
阅读全文
posted @ 2013-11-12 21:08 i梦
阅读(418)
评论(0)
推荐(0)
2013年10月20日
hdu 2037(贪心)
摘要: #include #include #include #include using namespace std;typedef struct Channel{ int s,t;}channel;int cmp(const void *a, const void *b){ channel *c = (channel *) a; channel *d = (channel *) b; if(c->t != d->t) return c->t - d->t; else return c->s - d->s;}//qsort/*int cmp(const chann
阅读全文
posted @ 2013-10-20 15:57 i梦
阅读(172)
评论(0)
推荐(0)
2013年10月18日
hdu 1059(多重背包)
摘要: #include #include #include using namespace std;int F[210000];int V;void ZeroOnePack(int cost, int weight){ for(int i = V; i >= cost; i --) if(F[i-cost] + weight > F[i]) F[i] = F[i-cost] + weight;}void CompletePack(int cost, int weight){ for(int i = cost; i F[i]) F...
阅读全文
posted @ 2013-10-18 17:47 i梦
阅读(179)
评论(0)
推荐(0)
2013年10月15日
hdu 1058 && poj 2247
摘要: #include #include using namespace std;int a[5850];int Min(int a, int b, int c, int d){ int x = a > n){ if(n == 0) break; cout << "The " << n ; if(n % 10 == 1 && n % 100 != 11) cout << "st " ; else if(n % 10 == 2 && n % 100 != 12) cout <<
阅读全文
posted @ 2013-10-15 14:31 i梦
阅读(136)
评论(0)
推荐(0)
2013年10月8日
线性表之顺序表
摘要: #include#includeusing namespace std;#define Max 100#define Size 10typedef int Type;typedef struct { Type *data; int length; int listsize; int increment;}Sqlist;void InitList(Sqlist &L){ L.data = (Type *)malloc(Max*sizeof(Type)); L.length = 0; L.listsize = Max; L.increment = Size;...
阅读全文
posted @ 2013-10-08 17:34 i梦
阅读(142)
评论(0)
推荐(0)
2013年7月28日
快排
摘要: void quicksort(int *a, int n, int l, int r){ int lb,ub,key; lb = l; ub = r; key = a[lb]; while(lb key) {ub --;} if(lb 0) quicksort(a, lb, l, lb-1); if(r - ub > 0) quicksort(a, n-1-lb, lb+1, r);}希望下次贴贴的划分代码是自己写的。。
阅读全文
posted @ 2013-07-28 17:15 i梦
阅读(112)
评论(0)
推荐(0)
2013年7月19日
hdu oj 1020
摘要: #include#include#define maxn 10000int main(){ char str[maxn]; int N; int i,j,count; int flag[1000]={1}; scanf("%d" ,&N); while(N--) { scanf("%s" ,str); i = 0; int k = 0; for( ;str[i] != '\0' ; ) { count = 1; for(j = i + 1 ...
阅读全文
posted @ 2013-07-19 10:44 i梦
阅读(148)
评论(0)
推荐(0)
1
2
下一页
公告