摘要: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each inp 阅读全文
posted @ 2020-10-25 08:16 WingWing111 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 100层楼,两个鸡蛋。某层之上扔鸡蛋就会碎。问至少要测试多少次才能找出这层楼来?思路:首先要理解清楚题意,本题不是要找在哪一层以上会把鸡蛋扔破!而是我们假设在W层以上会把鸡蛋仍破,现在问至少要测试Y次才能找到这个W层?求的是Y另外一个要注意的是本题中要基于扔的人运气最差的情况,即要保证在worst case下也能找到。定义W层位蛋破层,则我们第一次从第x层扔蛋下去,有两种可能:1) 蛋破了:这说明了两点 1.我们手上仍然有n-1颗蛋 2.蛋破层一定在1...x-1之间,这里共有x-1-1+1 =>x-1数量的嫌疑楼层2)蛋没破:这也说明了两点 1.我们手上仍然有n颗蛋 2.蛋破层一定在. 阅读全文
posted @ 2013-12-26 02:35 WingWing111 阅读(943) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2013-07-14 16:23 WingWing111 阅读(1) 评论(0) 推荐(0) 编辑
摘要: sdfsdfstatic void Main(string[] args) { int[] list = new int[1001]; for (int i = 1; i < 1001; i++) { list[i - 1] = i; } Random random = new Random(); list[1000] = random.Next(1, 1000); int sum1 = 0; ... 阅读全文
posted @ 2013-07-14 16:22 WingWing111 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 七种qsort排序方法一、对int类型数组排序七种qsort排序方法一、对int类型数组排序int num[100];Sample:int cmp ( const void *a , const void *b ){return *(int *)a - *(int *)b;}qsort(num,100,sizeof(num[0]),cmp);二、对char类型数组排序(同int类型)char word[100];Sample:int cmp( const void *a , const void *b ){return *(char *)a - *(int *)b;}qsort(word,10 阅读全文
posted @ 2013-03-15 21:25 WingWing111 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Physics teachers in high school often think that problems given as text are more demanding than pure computations. After all, the pupils have to read and understand the problem first!So they don't state a problem like ``U=10V, I=5A, P=?" but rather like ``You have an electrical circuit that 阅读全文
posted @ 2013-03-15 15:47 WingWing111 阅读(154) 评论(0) 推荐(0) 编辑
摘要: BackgroundLucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center is at (0,0), and the cake's length of radius is 100.There are 2N (N is a integer, 1 #include #include #include #include #include #include . 阅读全文
posted @ 2013-03-15 09:19 WingWing111 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 大家都知道,递归的本质和栈数据的存取很相似了,都是先进去,但是往往最后处理!再者对于递归函数的局部变量的存储是按照栈的方式去存的,对于每一层的递归函数在栈中都保存了本层函数的局部变量,一边该层递归函数结束时能够保存原来该层的数据!如图: 如上图递归式依次往下进行的,并且在该层递归函数还没结束即将进入下一层递归调用时,将会把该层函数中的局部变量保存起来,以供下次使用! 好了,以上是递归函数的数据存储方式,可是有时候我们又得抓头了,递归的话,有时候又很难理解,貌似总也想不通! 于是我又把每一层递归函数化分为三部分了,第一部分:是递归调用前的一些数据处理,判断以及递归结束判断(当然了... 阅读全文
posted @ 2013-03-14 03:33 WingWing111 阅读(311) 评论(0) 推荐(0) 编辑
摘要: Eclipse是著名的跨平台的自由集成开发环境(IDE)。6月22日Eclipse 3.7 正式发布,代号是 Indigo 。在 Windows 7 下初始后化,发现界面变化不大,但中文字体却面目全非,小得根本看不见,而且也看起来很不爽。其实这是 Eclipse 的默认字体换了,以前的一直是 Courier New ,这次eclipse用的字体是 Consolas ,这是一个很好的编程字体了,无奈就是中文默认太小了。于是上网找了 Consolas 和微软雅黑混合字体,完美解决了中文字体小的问题,同时保持了Consolas字体的优雅,效果如下图:是不是比较满意?哈哈,那就赶紧下载这个混合字体吧。 阅读全文
posted @ 2013-03-13 16:13 WingWing111 阅读(184) 评论(0) 推荐(0) 编辑
摘要: This is a problem you can face while developing applications in Eclipse here is a solution for this problem.And also a bug reported for this problem hereWindows Menu –> Preferences –> General (expand it) –> Workspace (click on it).Look for a box “Text File Encoding”. Default will be “Cp1252 阅读全文
posted @ 2013-03-13 16:12 WingWing111 阅读(306) 评论(0) 推荐(0) 编辑