自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(23)
  • 资源 (1)
  • 收藏
  • 关注

原创 const\#define\inline的特点及区别

一、#define1、宏定义只是简单的文本替换,所以注意将变量加上括号,例#include#define SQR(x) (x*x)int main(){ int a, b = 2; a = SQR(b + 3); printf("a=%d\n", a); return 0;}预期结果:(b+3)*(b+3)=25;实际结果:b+3*b+3=11;2、宏定义求最大值最小

2015-06-30 20:47:54 1353

原创 extern “C”

一、extern “C”包含双重定义第一:被它修饰的目标是“extern”。也就是告诉编译器,其声明的函数和变量是可以在本模块或是其他模块中使用。通常,在模块的头文件中对本模块的提供给其他模块引用的函数和全局变量以关键字extern声明。第二:被它修饰的目标是“C”。也就是说其修饰的变量和函数是按照C语言的方式编译和连接的。作为一种面向对象的语言,C++支持重载,而过程式的c语言不

2015-06-30 20:17:10 324

原创 牛客网(阿里巴巴2010搜索研发C++工程师笔试卷)

题1:20个阿里巴巴B2B技术部的员工被安排为4排,每排5个人,我们任意选其中4人送给他们一人一本《effective c++》,那么我们选出的4人都在不同排的概率为答案:A:5^4*5!*15!/20!                  B:4^5*5!*15!/20!                          C:5^4*4!*16!/20!

2015-06-30 17:31:00 885

原创 牛客网(c++专项练习)

题6:阅读以下代码:class parent { public: virtual void output(); }; void parent::output() { printf("parent!"); } class son : public parent { public: virtua

2015-06-30 16:40:16 4445

原创 牛客网(搜狗2015 C++工程师笔试题)

共36题,对16题(机器学习和windows内核部分错题未做解答)题2:以下代码的输出是()int a[5]={1,2,3,4,5};int *ptr=(int*)(&a+1);printf("%d,%d",*(a+1),*(ptr-1));答案:A:1,2   B:2,5   C:2,1   D:1,5解析:注意*(a+1)与&a+1的区别,a 代表的是int * 每次步长为一个

2015-06-29 20:32:56 1265

原创 牛客网( C/C++工程师能力评估)

题3:问x等于什么?enum string{ x1, x2, x3=10, x4, x5, } x;答案:A:5   B:12    C:0      D:随机值解析:这是一个全局变量,存储在数据区,默认值为0题11:设已经有A,B,C,D4个类的定义,程序中A,B,C,D析构函数调用顺序为

2015-06-21 16:13:09 1443

转载 关于基类与派生类之间对象、指针等转化关系的小结

先上一段代码:#include using namespace std;//没有使用虚函数的继承派生关系class Base{public: Base(int i = 0):ival(i){} void getVal() { cout<<ival<<endl; }private: int ival;};class Derived:public Base{p

2015-06-19 15:43:35 476

原创 牛客网(C/C++工程师综合练习卷)

题2:int x[6][4],(*p)[4]: p=x;   则*(p+2)指向哪里?A:x[0][1]      B:x[0][2]     C:x[1][0]      D:x[2][0] 题解:int  (*p)[4]表示一个数组指针,p指向一个含有4个int元素的数组。区别int  *p[4],这个表示一个指针数组,该数组有4个元素,每个元素都是一个指针。题

2015-06-18 17:27:22 956

原创 Eclipse插件开发——工程创建

插件的体系结构:Eclipse平台是IBM向开发源码社区捐赠的开发框架,是一个成熟的、精心设计的以及可扩展的体系结构。其主要价值是它为创建可扩展的集成开发环境提供了一个开放源码平台。这个平台允许任何人构建与环境和其它工具无缝集成的工具。工具与 Eclipse 无缝集成的关键是插件。除了小型的运行时内核之外,Eclipse 中的所有东西都是插件。从这个角度来讲,所有功能部件都是以同等的方式创建的

2015-06-17 16:55:08 1535

原创 Divide Two Integers

题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思想:在不使用乘法、除法和取余的条件下,还可以通过采用减法的形式来计算除法。写出相应代码,提交LeetCode发现出现超时错误。查看Lee

2015-06-16 17:43:01 298

原创 Reverse Nodes in k-Group

题目:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as

2015-06-15 16:44:25 376

原创 Swap Nodes in Pairs

题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant spac

2015-06-10 22:22:50 291

原创 Merge k Sorted Lists

题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:两两个的合并,得到最后的结果。这里采用的是将1,2合并,3,4合并,然后再不断合并,直到满足条件。如果先将1,2合并,再将其结果与3合并,依次类推则会出现超时现象。代码:s

2015-06-10 21:10:17 265

原创 Generate Parentheses

题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "(

2015-06-10 16:09:55 343

原创 Merge Two Sorted Lists

题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路:遍历,排序代码:#include #include using

2015-06-09 18:57:34 234

原创 Valid Parentheses

题目:Given a string containing just the characters '(', ')','{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all

2015-06-09 17:29:30 227

原创 Remove Nth Node From End of List

题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end,

2015-06-09 16:48:53 231

原创 4Sum

题目:Given an array S of n integers, are there elements a,b, c, and d in S such that a + b +c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:El

2015-06-09 15:11:22 252

原创 Letter Combinations of a Phone Number

题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit

2015-06-09 10:20:50 354

原创 3Sum Closest

题目:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have ex

2015-06-08 20:45:02 240

原创 3SUM

题目:Given an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b

2015-06-08 16:39:56 266

原创 Longest Common Prefix

题目:Write a function to find the longest common prefix string amongst an array of strings.(写一个求最长前缀的函数)思路:两两相比求最长前缀,如有字符串:"my_date","my_daay","my_day","my_dmonth","my_dyear","my_dmouse",将第一个子串以第二个字串相

2015-06-04 16:19:16 372

转载 最长回文子串

最长回文子串      最长回文子串是最初我在网易笔试的时候遇见的,当时天真的把原字符串S倒转过来成为S‘,以为这样就将问题转化成为了求S和S’的最长公共子串的问题,而这个问题是典型的DP问题,我也在前面的文章中介绍了3中解决这个问题的方法。但是非常可惜,后来才知道这个算法是不完善的。那么到底为什么呢?听我慢慢道来。S=“c a b a”  那么  S' = “a b a

2015-06-02 19:53:47 310

按优先级调度

C语言编程实现操作系统中的按优先级调度算法,,

2012-12-28

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除