- 博客(44)
- 资源 (3)
- 收藏
- 关注
转载 使用auto_ptr需要注意的事项
a. auto_ptr定义于头文件memory中;b. auto_ptr只能用来管理单个动态创建的对象,而不能管理动态创建的数组;c. 和其他copy和assign不同,auto_ptr的copy和assign会改变右边的操作数,assignment符号的两边的auto_
2011-08-01 22:11:46
443
转载 不要在析构函数中抛出异常
转自:http://blog.youkuaiyun.com/zdl1016/article/details/42042451: 可以在析构函数中抛异常吗? 不可以! 虽然语法上并没错,但会对整体系统带来重大隐患!! 2: 那么如何保证析
2011-08-01 10:05:58
728
原创 VC6.0 使用技巧
Vc++6.0如何同时打开两个工程(转) 现象: 经常会碰到想要同时打开两个或者更多的*.dsw文件,但是你打开第二个的时候就会把第一个覆盖掉,非常的烦人!解决得方法: 找到“控制面板”,打开“文件夹选项”, 然后打开“文件类型选项” 在已注册的文件类型中找到 DSW Project Workspace 选中,然后点击高级选项,
2011-06-21 15:53:00
1020
原创 Python中的列表推导式(list comprehension)
列表推导式(list comprehension)是一种方便简介的语法形式,我们可以利用它将一个列表经过过滤后转换成另一个列表,也可以利用它将函数应用于列表中的元素。列表推导式如以下书写形式: [表达式 for 变量 in 列表] 或者: [表达式 for 变量 in 列表 if 条件] 例如,下列代码:li=[1,2,3,4,5,6,7,8,9]print
2011-06-15 16:18:00
2567
1
原创 读写BMP文件
转载http://www.blogjava.net/georgehill/articles/6549.html 6.1 BMP文件格式6.1.1 简介位图文件(Bitmap-File,BMP)格式是Windows采用的图像文件存储格式,在Windows环境下运行的所有图像处理软件都支持这种格式。Windows 3.0以前的BMP位图文件格式与显示设
2011-06-11 22:17:00
1032
1
原创 C语言时间相关
<br />#include <ctime><br />#include <cstring><br />#include <stdio.h><br /><br />int main()<br />{<br /> time_t t1,t2;<br /> t1 = 1167609600;<br /> t2 = 1180656000;<br /> char tmp[64];<br /> strftime( tmp, sizeof(tmp), "%Y
2011-04-06 15:29:00
414
原创 写在2010年的最后一天
<br /> 转眼间,2010年就将过去。这是求学中关键的一年,但却不是我进步很大的一年,你早应该明白都要靠自己去学习,但有时仍会不知所措。反思...<br /> 新的一年,这是我最后的机会了!<br /> <br /> 自己最大的毛病就是:<br /> 1.目标不明确<br /> 2.浮躁<br /> <br /> 找到了问题就要针对性的解决,今天看到一篇《天才也是训练出来的》,还有泰戈尔的“最简单的音调需要艰苦的练习”。<br /> <br /> 决定看一本书的
2010-12-31 21:17:00
422
原创 今天
<br /> 现在我坐在实验室里,看书、上网、写博客。这让我想起了去年的今天,去年的今天我经历了一场重感冒,刚从医院里出来,而且还有着很大的考试压力。还好,一切都过去了。明年的今天我会是在哪里呢?<br /> 由你决定!
2010-12-28 10:40:00
324
原创 2.2 subset
<br />ubset Sums<br />JRM<br />For many sets of consecutive integers from 1 through N (1 <= N <= 39),one can partition the set into two sets whose sums are identical.<br />For example, if N=3, one can partition the set {1, 2, 3} in one way sothat
2010-12-26 20:42:00
560
原创 2.2 lamps
Party Lamps<br />IOI 98<br />To brighten up the gala dinner of the IOI'98 we have a set of N(10 <= N <= 100) colored lamps numbered from 1 to N.<br />The lamps are connected to four buttons:<br /> Button 1: When this button is pressed, all the lamps
2010-12-22 11:29:00
405
原创 2.2 runround
Runaround Numbers<br /><br /> Runaround numbers are integers with unique digits, none of which iszero (e.g., 81362) that also have an interesting property, exemplifiedby this demonstration:If you start at the left digit (8 in our number) and count th
2010-12-21 20:52:00
516
原创 Windows下如何使用高版本OpenGL
Windows只是支持OpenGL1.1(win7依然如此,甚至显示还有一些问题),但是显卡可能可以从硬件上直接实现了高版本的OpenGL的相关函数。在做开发如何调用高版本的OpenGL函数啊? 我们先来看一下,如何查看显卡支持的OpenGL版本和相关函数扩展:查看显卡支持的OpenGL版本:glGetString(GL_VERSION);查看支持的相关扩展: glGetString(GL_EXTENSIONS);更为详细的信息查看。http://www.opengl.org/wiki/
2010-12-21 18:00:00
4942
1
转载 vs2010下OpenGL的配置
http://www.cnblogs.com/rogee/archive/2010/10/18/1854356.html
2010-12-16 22:28:00
582
原创 2.2 preface
<br />好久没做题了,坚持!Preface Numbering<br /><br /> A certain book's prefaces are numbered in upper case Roman numerals.Traditional Roman numeral values use a single letter to represent acertain subset of decimal numbers. Here is the standard set:
2010-12-15 19:05:00
443
原创 愿望要靠努力实现
<br /> 听说今天晚上有流星雨,在去实验室的路上我就格外注意天空,看看能不能看见流星。可能是由于天气的原因吧,我并未看到流星。<br /> 可是,我还在想,要是看见流星,让我许三个愿望,我会许什么愿呢?<br /> 1.父母身体健康。<br /> 2.哥哥能走的一步比一步好。<br /> 3.我明年能找一个好工作。<br /> <br /> 细想一下,是不是有点太小我了呢?不过,没关系,这些都是我当前真正的愿望啊。<br /> 愿望是这些,但是细想一下就会发现,
2010-12-14 20:30:00
791
原创 2.1 castle
<br />深度优先搜索The Castle<br />IOI'94 - Day 1<br /> In a stroke of luck almost beyond imagination, Farmer John wassent a ticket to the Irish Sweepstakes (really a lottery) for hisbirthday. This ticket turned out to have only the winning numberfor the l
2010-12-05 16:30:00
480
原创 2.1 sort3三值排序
Sorting a Three-Valued Sequence <br />IOI'96 - Day 2<br /> Sorting is one of the most frequently performed computational tasks.Consider the special sorting problem in which the records to be sortedhave at most three different key values. This happen
2010-12-03 21:27:00
683
原创 2.1 frac1
Ordered Fractions<br /><br /> Consider the set of all reduced fractions between 0 and 1 inclusivewith denominators less than or equal to N.<br />Here is the set when N = 5:0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1<br /><br /> Write a program that
2010-12-03 21:26:00
562
原创 2.1 Hamming
Hamming Codes<br />Rob Kolstad<br /> Given N, B, and D: Find a set of N codewords (1 <= N <= 64),each of length B bits (1 <= B <= 8), such that each of the codewordsis at least Hamming distance of D (1 <= D <= 7) away from each ofthe other codewords
2010-12-01 18:23:00
450
原创 2.1 holstein
<br />好久没有做题了。<br />此题的关键是组合的产生,细想一下也是可以用递归做的。<br />我使用了简单的模拟。<br /> Healthy Holsteins<br />Burch & Kolstad<br />Farmer John prides himself on having the healthiest dairy cowsin the world. He knows the vitamin content for one scoop of eachfeed type an
2010-12-01 12:17:00
392
原创 一个月了
<br /> 不知不觉自己开这个博客已经一个月了,这真是值得铭记的一个月啊。<br /> 这个月前面那阵,自己还挺有状态的,看书,做题,写博客,不亦乐乎。可以校医院那个江湖医生打乱了这一切,她着实吓了我一条。那几天,自己真的是都没有信心了,真是自己这几年来经历过最低谷的几天。每天都在担心...细想一下,那几天还真是傻。有时候真的只是在乎自己怎么想。很好,我已经走过来了,不管未来怎样,我都会将乐观坚定的走下去。因为有我爱的人和爱我的人。<br /> 开始做联发科的项目了,充实真好。<br /
2010-11-22 21:30:00
289
原创 1.5 超级肋骨质数
Superprime Rib<br />Butchering Farmer John's cows always yields the best prime rib. Youcan tell prime ribs by looking at the digits lovingly stamped acrossthem, one by one, by FJ and the USDA. Farmer John ensures that apurchaser of his prime ribs g
2010-11-12 12:20:00
677
原创 1.5 回文质数
Prime Palindromes<br />The number 151 is a prime palindrome because it is both a prime numberand a palindrome (it is the same number when read forward as backward).Write a program that finds all prime palindromes in the range of twosupplied numbers a
2010-11-12 11:38:00
599
原创 1.5 numtri
<br />Number Triangles<br /><br />Consider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally
2010-11-11 13:00:00
429
原创 1.4 milk3 倒牛奶
<br />广度优先搜索,用数组记录到达过的状态<br /> <br />Mother's Milk<br /><br />Farmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty while buc
2010-11-08 13:12:00
4359
原创 1.4 clocks 枚举
<br />注意转变思路,每个操作最多执行三次,所有解空间是4**9个,枚举所有可能的操作<br />钟表a受影响的操作有1,3,4<br />用上述方法,判断每个操作后的状态<br />输出即可<br /> <br />The Clocks<br />IOI'94 - Day 2<br />Consider nine clocks arranged in a 3x3 array thusly:<br /><br />|-------| |-------| |-------|
2010-11-07 21:29:00
400
原创 1.4 ariprog
<br />暴力搜索,尽可能的提高效率<br /> Arithmetic Progressions<br /><br /> An arithmetic progression is a sequence of the form a, a+b, a+2b,..., a+nb where n=0,1,2,3,... . For this problem, a is a non-negativeinteger and b is a positive integer.<br /> Write a pro
2010-11-05 23:04:00
495
原创 1.3 crypt1 简单枚举
<br />Prime Cryptarithm<br /><br />The following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set of N digits into the positions marked with *. If the set of prime digits {2,3,5,7} is selected, the cr
2010-11-04 19:55:00
502
原创 tips
<br />我们知道,要想把字符串转化问数字只需简单调用atoi()函数即可<br />例如:int i = atoi( "512.035" ); <br /><br />但是如何把数字转换为字符串呢?<br />用sprintf就可以了<br /><br />sprintf(string, "%d", number);<br /><br />同理,也可以用sprintf把long型或浮点型转换为字符串(使用%ld或%f)。<br />也就是
2010-11-04 19:54:00
294
原创 字符串和数字的相互转换
<br />我们知道,要想把字符串转化问数字只需简单调用atoi()函数即可<br />例如:int i = atoi( "512.035" ); <br /><br />但是如何把数字转换为字符串呢?<br />用sprintf就可以了<br /><br />sprintf(string, "%d", number);<br /><br />同理,也可以用sprintf把long型或浮点型转换为字符串(使用%ld或%f)。<br />也就是说,可以把sprinf看作是atol和a
2010-11-02 12:20:00
331
原创 字符串字面量
问题:以下的初始化有什么区别?char a[] = "string literal";char *p = "string literal";为什么当向p[i]复制的时候,程序崩溃了?解释:字符串字面量(C语言源程序中用双引号包含的字符串),有两种稍微有区别的用法:1.用作数组的初始化(如同在char a[]的声明中),它指明该数组中字符的初始值;2.转化为一个无名的静态字符数组,可能会在只读内存中,这就导致它不能被修改。在表达式环境中,数组通常立即转化为一个指针,因此第二个声明把p初始化成指向无名数组的第一
2010-11-01 22:13:00
693
原创 作为函数参数的指针
<br />例1<br />void f(int *ip){ static int dummy = 5; ip = &dummy;}//但是当如下调用时调用者的指针没有任何变化int *ip;f(ip);<br /> <br />例2<br />我为malloc写了一个小小的封装函数,它为什么不行?<br />#include <stdio.h>#include <stdlib.h>mymalloc(void *retp, size_t size){
2010-11-01 21:38:00
369
原创 1.3 Barn Repair 修理牛棚,还是贪心算法
<br />书读百遍,其意自见。<br /> <br />还是一道贪心算法的题目,贪心的核心就是从局部最优解推得全局最优解。<br /> <br />Barn Repair<br /><br />It was a dark and stormy night that ripped the roof and gates off the stalls that hold Farmer John's cows. Happily, many of the cows were on vacation, so th
2010-10-31 14:29:00
1193
原创 1.3 mixing milk 简单贪心算法
Mixing Milk<br />Since milk packaging is such a low margin business, it is importantto keep the price of the raw product (milk) as low as possible. HelpMerry Milk Makers get the milk they need in the cheapest possible manner.<br />The Merry Milk Make
2010-10-31 13:09:00
783
原创 1.2 dualpal 还是进制和回文
<br />认真读题,题目要求是从2到10进制出现两次以上回文才算。<br /> <br />Dual Palindromes<br />Mario Cruz (Colombia) & Hugo Rickeboer (Argentina)<br /><br />A number that reads the same from right to left as when read from left to right is called a palindrome. The number 12321
2010-10-29 15:37:00
402
原创 1.2 palsquare 转化为对应进制,再判断是否为回文
Palindromic Squares<br />Rob Kolstad<br /> Palindromes are numbers that read the same forwards as backwards.The number 12321 is a typical palindrome.<br /> Given a number base B (2 <= B <= 20 base 10), print all theintegers N (1 <= N <= 300 base
2010-10-29 15:04:00
353
原创 1.2 namenum 递归枚举
<br />Name That Number<br /><br />Among the large Wisconsin cattle ranchers, it is customary to brand cows with serial numbers to please the Accounting Department. The cow hands don't appreciate the advantage of this filing system, though, and wish to ca
2010-10-28 20:18:00
435
原创 流迭代器
<br />我们可以用这种方式容易的表示输入和输出流,例如:<br /> <br />ofstream_iterator<string> oo(cout); //assigning to *oo is to write to cout<br />*oo = "Hello,"; //meaning cout<<"Hello,"<br />++oo; //get ready for next output operation<br />*oo = "World!/n"; //meaning cou
2010-10-28 11:36:00
478
原创 一种灵活的find_if的第三个参数----函数对象
find_if的一个实现templateT find_if(T first, T last, Pred pred){ while(first!last && !pred(*first)) ++first; return first;}find_if()要求谓词具有一个参数,以使的它能够判断 pred(*first)是true还是false;我们可以比较容易的编写一个谓词以检查一个给定值的属性,例如“给定字符串是否包含x”"给定值是否大于32"但是,我们想在谓词中也添加一个参数时,该怎么做呢
2010-10-27 21:14:00
1765
原创 1.1 transform 简单模拟
自己都觉得自己写的代码丑... Transformations A square pattern of size N x N (1
2010-10-26 23:30:00
326
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人