上一页 1 2 3 4 5 6 7 8 9 ··· 16 下一页
摘要: 1、实现一个函数,对一个正整数n,算得到1需要的最少操作次数。操作规则为:如果n为偶数,将其除以2;如果n为奇数,可以加1或减1;一直处理下去。例子:func(7) = 4,可以证明最少需要4次运算n = 7n-1 6n/2 3n-1 2n/2 1要求:实现函数(实现尽可能高效) int func(unsign int n);n为输入,返回最小的运算次数。给出思路(文字描述),完成代码,并分析你算法的时间复杂度。要想到位操作,除以2,分析下,就可以。 1 #include <iostream> 2 3 using namespace std; 4 5 int func(unsign 阅读全文
posted @ 2012-09-21 16:40 可乐爱上了雪碧 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Given a list of integers, your task is to write a program to output an integer-valued list of equal length such that the output element at index 'i' is the product of all input elements except for the input element at 'i'.In other words, let inputArray by an integer array of length & 阅读全文
posted @ 2012-09-20 19:59 可乐爱上了雪碧 阅读(208) 评论(0) 推荐(0) 编辑
摘要: ShellExecute(NULL, "open", "rundll32.exe", "url.dll,FileProtocolHandler http://www.google.com",NULL,SW_SHOWNORMAL); 阅读全文
posted @ 2012-09-19 17:23 可乐爱上了雪碧 阅读(333) 评论(0) 推荐(0) 编辑
摘要: Frequency Counting of Words / Top N words in a document.Given N terms, your task is to find the k most frequent terms from given N terms.Input format:First line of input contains N, denoting the number of terms to add.In each of the next N lines, each contains a term.Next line contains k, most frequ 阅读全文
posted @ 2012-09-17 15:25 可乐爱上了雪碧 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 额,拖了好久,都没时间做~一开始想成用数组实现没有看清楚题目啊。链表操作就是要画出来,写的时候细心点,特别是注意之前的变量有没有改变,要加个临时变量来存。链表易于插入,删除。数组是随机访问。把两者结合起来用就更好。 1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 typedef unsigned int UINT; 7 typedef struct SingleNode 8 { 9 SingleNode():next(NULL){} 10 string data;... 阅读全文
posted @ 2012-09-17 09:29 可乐爱上了雪碧 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 16 下一页