
c/c++
文章平均质量分 54
ch209209
这个作者很懒,什么都没留下…
展开
-
pat 1002
还有一个测试用例没有通过,暂存于此。// pat_test.cpp : 定义控制台应用程序的入口点。//#define __1002__ENABLE__#ifdef __1002__ENABLE__#include "stdio.h"#define MAXN 1000typedef struct poly{int exp;float cof;原创 2012-03-24 21:34:51 · 703 阅读 · 0 评论 -
宏定义中的字符连接
今天看webkit的代码,于是也照个模仿两个,没想到,结果和想的不一致,遂查找原因。 #define ENABLE(FATURE) DEFINE_##FATURE_ENABLE 在函数中ENABLE(HELLO) 期望有 DEFINE_HELLO_ENABLE 但是却没有出现。 这是为什么呢,经过几轮测试之后 ,我得出结论,宏展开的时候 , #原创 2011-05-04 21:44:00 · 978 阅读 · 0 评论 -
endl和'/n'
1.endl是一个特殊值,称为操纵符,将它写入输出流时,不仅具有输出换行的效果,而且它刷新与设备关联的缓冲区,通过刷新缓冲区,用户可立即看到写入到流中的输出;'/n'仅仅是一个换行符,将它写入到输出流时,只能起到一个换行的作用,不能刷新输出。 因此建议,在能用cout 2.#include "stdafx.h"#include #include int _tma转载 2012-11-10 20:55:56 · 712 阅读 · 0 评论 -
0-1背包问题
背包问题有0-1背包问题和fraction背包问题,前者规定每个物品要么选,要么不选,而fraction knanpsack允许选取一个物品的一部分,0-1背包问题是NP难的,而fraction knapsacks的复杂度是O(n*logn), 只需要将单位物品的价值按降序排列,利用贪心策略选取即可得到最优解。给定一个背包,容量为C,有n个物品,重量为n维行向量w,价值为n维行向量v. |v|转载 2012-11-15 09:26:03 · 879 阅读 · 0 评论 -
PAT-1015
1015. Reversible Primes (20)题目地址:http://pat.zju.edu.cn/contests/pat-practise/1015A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For exa原创 2012-11-17 18:31:05 · 593 阅读 · 0 评论 -
PAT -1007
1007. Maximum Subsequence Sum 题目地址:http://pat.zju.edu.cn/contests/pat-practise/1007Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ...,原创 2012-11-17 13:34:55 · 588 阅读 · 0 评论 -
PAT-1040
1040. Longest Symmetric String题目地址:http://pat.zju.edu.cn/contests/pat-practise/1040Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is原创 2012-11-18 12:16:33 · 583 阅读 · 0 评论 -
PAT-1032
1032. Sharing (25)题目地址:http://pat.zju.edu.cn/contests/pat-practise/1032 To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may le原创 2012-11-22 11:56:48 · 630 阅读 · 0 评论 -
Pascal's Triangle --Leetcode
http://leetcode.com/onlinejudge#question_118Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,原创 2013-07-22 21:18:18 · 598 阅读 · 0 评论