2012年11月19日
摘要: 例1:均分纸牌int main(){ int i, n, s = 0; long v = 0; printf("请输入纸牌堆数:"); scanf("%d", &n); int a[n]; printf("请输入%d堆纸牌各堆数目\n", n); int t; for(t = 0; t < n; t++){ scanf("%d", &a[t]); v = v + a[t]; } printf("各堆纸牌的数量为:\n");... 阅读全文
posted @ 2012-11-19 21:57 lemon06413 阅读(309) 评论(0) 推荐(0)
摘要: ref:http://zhangpingan2005.blog.163.com/blog/static/6722954220103286271083/ http://www.cnblogs.com/lcfigu/archive/2011/02/11/1951398.html 自己在搜索引擎中键入 bubble sort 已经有很多次,原因是我总是忘记冒泡排序是怎样实现的,或者看见别人的代码号称是冒泡排序,总是拿不准。所以自己写一篇博文,记录最简单、不经过优化的冒泡排序。 冒泡排序是最基本的排序算法,常被做为内部排序的第一个排序算法进行讲解。它的原理非常简单,只是一个两层循环,每次... 阅读全文
posted @ 2012-11-19 16:12 lemon06413 阅读(225) 评论(0) 推荐(0)
  2012年11月11日
摘要: 今天在上海交大闵行校区,笔试了vmware。写一篇日志,记录下笔试的题目。试题形式:90分钟。20道不定项选择题,占60%分数;2个写程序的题目,占40%分数。全英文。ps: 晚上在北邮人论坛上和同学们讨论了下,试题一共至少有四套,上海北京各两套。我做的是 version 1, Shanghai. 北京的版本,时间是150分钟。30个不定项选择,有三道或四道写程序题目的两种。难度,因为没做过,不好衡量,不过上海的题目少并不就比北京的版本简单。从后往前写吧,因为后边的题目记得清楚些。题目后边的 ref 是我搜索到一些相关技术文章,供我写完这篇随笔后慢慢学习使用。一. 写程序题目:1. 给定一个 阅读全文
posted @ 2012-11-11 22:30 lemon06413 阅读(1676) 评论(7) 推荐(0)
摘要: 1.递归方法List* rev (List * head){ List *rHead; if(!head) { // 链表为空 return head; } else if(!head->next) // 链表只有一个节点 { return head; } else { rHead = rev(head->next); head->next->next = head; head->next = NULL; re... 阅读全文
posted @ 2012-11-11 21:15 lemon06413 阅读(111) 评论(0) 推荐(0)
  2012年11月7日
摘要: volatile 关键字的使用volatile从字面意思来看是“挥发性的”“不稳定的”。在一个变量前面加上这个关键字就是告诉compiler,这个变量是“不稳定的”,每次访问它的时候,都要去memory中重新读取它的值,而不能使用之前保存的该变量的暂时值。Volatileisa"typequalifier".Ittellsthecompilerthatthevariablemightchangewithoutitknowing.Thevolatilequalifiertellsthecompilerthatwheneveryouaccessthevariable,itsva 阅读全文
posted @ 2012-11-07 15:52 lemon06413 阅读(136) 评论(1) 推荐(1)
摘要: HashMap 和 TreeMap 比较TreeMapisanexampleofaSortedMap,whichmeansthattheorderofthekeyscanbesorted,andwheniteratingoverthekeys,youcnaexpectthattheywillbeinorder.HashMap,ontheotherhand,makesnosuchgarantee.Therefore,wheniteratingoverthekeysofaHashMap,youcan'tbesurewhatordertheywillbein.HashMapisaperfec 阅读全文
posted @ 2012-11-07 15:51 lemon06413 阅读(184) 评论(0) 推荐(0)
摘要: ConcurrentHashMap 和 Collections.synchronizedMap(map) 比较如果你有一个Map将会被几个线程同时修改,那么在JavaAPI中你有三种不同的同步Map实现可以选择:HashtableCollections.synchronizedMap(map)ConcurrentHashMap选择多了也是一种困扰:)首先,你可以抛开Hashtable了,这是一个旧的实现(继承自废弃的Dictioanry类),当它被用于synchronized时,会有严重的扩展性危机,现在已经不鼓励在新的项目中使用它了。下面讨论剩下的两种。根据需求,ConcurrentHash 阅读全文
posted @ 2012-11-07 15:49 lemon06413 阅读(659) 评论(0) 推荐(0)
摘要: Ref:http://stackoverflow.com/questions/1102891/how-to-check-a-string-is-a-numeric-type-in-java方法1: 先把 string 转换成 char 数组,然后判断每个 char 是否是 数字。public boolean isNumeric(String str) { char[] cs = str.toCharArray(); if ( !str) return false; for (Char a : cs) { if ( !C... 阅读全文
posted @ 2012-11-07 15:46 lemon06413 阅读(419) 评论(0) 推荐(0)