【笔试or面试】金山西山居2014校招笔试题

1.32位环境下

 

#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	char t1[] = "ab\0cd";
	char t2[6] = "abcd\0";
	int t3[4] = {'0', 0, '\0'};
	printf("%d\n",sizeof(t1));
	printf("%d\n",sizeof(t2));
	printf("%d\n",sizeof(t3));
	printf("%d\n",strlen((char*)t3));
	return 0;
}


输出:

 

 

6
6
16
1


解析:http://blog.csdn.net/chenjin_zhong/article/details/6097984

 

http://www.cnblogs.com/carekee/articles/1630789.html(这篇文章讲sizeof和strlen的区别讲得很好)

http://blog.csdn.net/ce123_zhouwei/article/details/6971544(这篇文章讲大端和小端规则讲得很好,挺好的博客)

 

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <bitset>
using namespace std;

int main()
{
	char t1[] = "ab\0cd";
	char t2[6] = "abcd\0";
	int t3[4] = {'0', 0, '\0'};
	printf("%d\n",sizeof(t1));
	printf("%d\n",sizeof(t2));
	printf("%d\n",sizeof(t3));
	printf("%d\n",strlen((char*)t3));
	cout << bitset<32>(t3[0]) << endl;
	cout << bitset<32>(t3[1]) << endl;
	cout << bitset<32>(t3[2]) << endl;
	cout << bitset<32>(t3[3]) << endl;
	char* ct3 = (char*)t3;
	cout << bitset<8>(ct3[0]) << endl;
	cout << bitset<8>(ct3[1]) << endl;
	cout << bitset<8>(ct3[2]) << endl;
	cout << bitset<8>(ct3[3]) << endl;
	return 0;
}


2.冒泡排序的算法的复杂度?

参考:http://zh.wikipedia.org/wiki/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95


3.C++的friend有什么缺点

参考http://blog.csdn.net/adriano119/article/details/5914443

http://www.cnblogs.com/BeyondAnyTime/archive/2012/06/04/2535305.html (挺不错的博客)


4.填空声明一个int类型的常引用变量i:_________=5;

 

const int& i = 5;


 

5.int i = 3, j = 2, k = 8;

k*=i-j++;

求j和k。

 

3
8

http://www.slyar.com/blog/c-operator-priority.html (C语言运算符优先级)

 

6.intel x86体系。

 

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <bitset>
using namespace std;

union
{
	int i;
	char x[2];
}a;

int main()
{
	a.x[0] = 5;
	a.x[1] = 2;
	printf("%d\n", a.i);
	return 0;
}


输出:

 

 

517


解析:很简单,只要知道union是将所有成员按照低地址存放还有大端和小端规则就行了。

 

http://blog.csdn.net/masefee/article/details/4160211


6.typedef和#define的用法和区别,应该如何选择?

参考:http://www.cnblogs.com/kerwinshaw/archive/2009/02/02/1382428.html


7.析构函数有什么作用,能否被重载?

参考:http://jaden.blog.51cto.com/1549175/324480


8.STL的vector、list的作用和区别?

参考:http://www.cppblog.com/Lee7/archive/2008/09/29/63035.html

http://blog.csdn.net/morewindows/article/details/6950917 (讲STL挺好的博客)


9.纯虚函数是什么,做什么用的?

参考:http://blog.csdn.net/Hackbuteer1/article/details/7558868 (有很多面试题的博客)


10.改错题,主要考字符串的知识:fgets,snprintf,strcmp,strchar,strncpy

参考自:http://blog.csdn.net/kenby/article/details/3284290

http://www.vimer.cn/2009/11/snprintf%E5%AE%B9%E6%98%93%E8%AF%AF%E8%A7%A3%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95.html

http://blog.csdn.net/xuefu2008/article/details/4662534

http://blog.csdn.net/sky2098/article/details/1530433

http://blog.csdn.net/nabber/article/details/2212891


11.解析xml,还是要用到字符串的知识。


12.动态规划题(待补充)


posted @ 2013-09-20 19:19  haoaina521  阅读(2552)  评论(0编辑  收藏  举报