面试笔记之深圳IT公司

5 篇文章 0 订阅

每个人都想当老板,马云说,“有梦想是好的,万一实现了呢”。

但是,不管你信不信,世界上,老板要比员工少。

找工作难,做好工作更难。

面试是你拿到工作的机会,

有面试就难免有笔试,公司的面试题目我认为在一年当中不会有很大改动的,所以可以参考下

以下是收集本人在这个月的面试时间里遇到的一些值得分享的面试题目,但愿能帮到同行或其它求职者!

为保护相关公司的隐私,本人在此不提供真实公司名字,若需要了解的,可以加本人QQ1258029407,获得进一步提示!!!!


company one: xxxxxxxxxxxxxxxxxx 性质:游戏

1、写出socket编程类型和基本函数及步骤。

2、如何获取当前文件的路径。

3、反转链表。

4、求1+2+3+........+n(如果你直接写 return n*(1+n)*1/2,而且还坚持的认为自己的答案对了,恭喜你,你可以回去等通知了(面试官的潜台词:你可以OUT了)。。。。)

5、智力题(由于本人智商不高,认为还是很难的)

(1)水杯倒水问题:给两个不同容量的杯子,要你想办法量出给定量的水(不是很难,运气好很快就找到思路)

(2)有若干条质地均匀的绳子,烧一条要1小时,问你如何想办法通过烧绳子来记1小时50分钟的时间

。。。。。还有很多暂时记不得了。。。。。。


company two: xxxxxxxxxxxxxxxxxx 性质:办公设备系统

1、c语言内存分配问题

NO.1
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str,"hello world");
printf(str);
}
请问运行 Test 函数后会是什么样的结果?
NO.2
char *GetMemory(void)
{
char p[] = hello world;
retrun p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
问题同 NO.1
NO.3
void GetMemory(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str,100);
strcpy(str,"hello");
printf(str);
}
问题同 NO.1
NO.4
void Test(void)
{
char *str = (char *)malloc(100);
strcpy(str,"hello");
free(str);
if(str != NULL)
{
strcpy(str,"world");
printf(str);
}
}
问题同 NO.1
我对以上问题的分析:
NO.1程序首先申请一个 char 类型的指针 str,并把 str 指向 NULL(即 str 里存的是 NULL
的地址, *str 为 NULL 中的值为0), 调用函数的过程中做了如下动作:
1 、申请一个 char 类型的指针 p,
2、把 str 的内容 copy 到了 p 里(这是参数传递过程中系统所做的) ,
3、为 p 指针申请了 100 个空间,
4、返回 Test 函数.最后程序把字符串 hello world 拷贝到 str 指向的内存空间里. 到这里错
误出现了!
str 的空间始终为 NULL 而并没有实际的空间.深刻理解函数调用的第 2 步,将不难发现问
题所在! (注意:传递的参数和消除的参数)
NO.2程序首先申请一个 char 类型的指针 str,并把 str 指向 NULL.调用函数的过程中做了
如下动作:
1申请一数组 p[]并将其赋值为 hello world(数组的空间大小为 12),
2返回数组名 p 付给 str 指针(即返回了数组的首地址).
那么这样就可以打印出字符串" hello world"了么?当然是不能的!
因为在函数调用的时候漏掉了最后一步. 也就是在第2步 return 数组名后,函数调用还要
进行一步操作,也就是释放内存空间. 当一个函数被调用结束后它会释放掉它里面所有的变
量所占用的空间.所以数组空间被释放掉了,也就是说 str 所指向的内容将不确定是什么东
西
NO.3正确答案为可以打印出 hello.但内存泄漏了! 需要用 free()函数进行释放。
NO.4申请空间,拷贝字符串,释放空间.前三步操作都没有任何问题.到 if 语句里的判
断条件开始出错了,因为一个指针被释放之后其内容并不是 NULL,而是一个不确定的值.
以 if 语句永远都不能被正确执行.这也是著名的"野"指针问题.所以我们在编写程序释放
一个指针之后一定要人为的将指针付成 NULL. 这样就会避免出现"野"指针的出现.有人
说"野"指针很可怕,会带来意想不到的错误.


company three: xxxxxxxxxxxxxxxxxx性质:Web后端(该公司题目:全英文,呵呵呵呵)

1、改错
void main()
{
unsigned int i;
char *a[] = {"a", "b", "c", "d", "e"};
for (i = 5; i>=0; --i)
{
printf("\n");
printf(a[i]);
printf("\n");
}
}

2、sizeof的应用
har str[] = “http://www.ibegroup.com/”
char *p = str ;
int n = 10;
请计算
(1)sizeof (str ) = ? 
(2)sizeof ( p ) = ? 
(3)sizeof ( n ) = ? 
void Foo ( char str[100]){
请计算
sizeof( str ) = ?(4)
}
void *p = malloc( 100 );
请计算
sizeof ( p ) = ?(5)
答:(1)25 (2)4 (3) 4 (4)4 (5)4
(6)
double *(*dub)[2][3] //double **dub
sizeof(dub) //&dub *dub **dub ***dub ****dub

3、位的反转,即给定一个数,要你输出它反转位后的值。
4、下面代码的作用是什么
HANDLE hMutex = CreateMutex(NULL, true, "isRun");
if (NULL == hMutex)
{
return false;
}
int err = GetLastError();
if (ERROR_ALREADY_EXISTS == err)
{
return false;
}
5、引用和指针的区别
(1、引用必须初始化,引用不可为常量。指针不需初始化,而且可以指向常地址。
(2、引用初始化后不可改变值,指针可以改变。
(3、引用传参不需重新分配内存,指针需要重新分配内存。

company four: xxxxxxxxxxxxxxxxxx 性质:股票期货

1、这题有点长,直接上代码,不多说了
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;


class CObject
{
public:
int m_a, m_b;
CObject(int a, int b): m_a(a), m_b(b)
{

}
CObject()
{

}
~CObject()
{
}
bool operator < (const CObject& obj);
bool operator > (const CObject& obj);
bool operator == (const CObject& obj);
CObject& operator = (const CObject& obj);
};


void Merge(vector<CObject>& dst,vector<CObject> src)
{
vector<CObject> temp;
int i, j, nDst, nSrc;

nDst = dst.size ();
nSrc = src.size ();


for (j = 0; j < nSrc; ++j)
{
for (i = 0; i < nDst; ++i)
{
if (src[j].m_a  >= dst[i].m_a)
break;
}
if (i >= nDst)
temp.push_back(src[j]);
}


vector<CObject>::iterator it1, it2, it;
it = dst.end ();
it1 = temp.begin ();
it2 = temp.end ();
dst.insert (it, it1, it2);
sort(dst.begin (), dst.end ());
}


void ShowObject(vector<CObject>& obj)
{
for (int i = 0; i < obj.size (); ++i)
{
cout << obj[i].m_a << " " << obj[i].m_b << endl;
}
cout << "_____________________________________" << endl;;
}


int main()
{
int i;
CObject dst[5];
CObject src[5];
for (i = 0; i < 5; ++i)
dst[i] = CObject(i+5, i+5);
for (i = 0; i < 5; ++i)
src[i] = CObject(i+2, i+2);

vector<CObject> dstObj(dst, dst + 5);
ShowObject(dstObj);
vector<CObject> srcObj(src, src + 5);
ShowObject(srcObj);
Merge(dstObj, srcObj);
ShowObject(dstObj);
return 0;
}


bool CObject::operator < (const CObject& obj)
{
return (m_a < obj.m_a) && (m_b < obj.m_b);
}
bool CObject::operator > (const CObject& obj)
{
return (m_a > obj.m_a) && (m_b > obj.m_b);
}
bool CObject::operator == (const CObject& obj)
{
return (m_a == obj.m_a) && (m_b == obj.m_b);
}
CObject& CObject::operator = (const CObject& obj)
{
m_a = obj.m_a;
m_b = obj.m_b;
return *this;
}

2、直接上代码
//不改变类CObject的实现在int中改变m_a,m_b的值
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;


class CObject
{
private:
int m_a, m_b;
public:
CObject(int a, int b):m_a(a),m_b(b)
{}
};
//不改CObject类的实现,将a值赋给m_a
void SetValue(CObject* obj, int a, int b)
{
if (obj != NULL)
{
delete[] obj;
obj = NULL;
}
obj = new CObject(a,b);
}


int main()
{
CObject* pObj = new CObject(1,2);


//DoTo:
SetValue(pObj,2,2);


delete[] pObj;
}

3、概率题:有一种产品A、B各占0.6、0.4,其中A次品为0.8,B次品为0.2,问从产品中随机收取一件为次品B的概率是多少?
4、智力题:A连所有的士兵都被消灭了,也许还有一个在医院,那么可以推论:

company five: xxxxxxxxxxxxxxxxxx 性质:航天信息服务
这家公司的题目说真的,很容易,只要懂得点计算机基本常识均可以答出,在此不再累赘了。。。。。

company six: xxxxxxxxxxxxxxxxxx 性质:通信设备
这个公司我只能说太好了,英语过四六级,是个女的长的漂亮点,面试官应该会考虑滴。。。。。。。。。。。。。。

company seven: xxxxxxxxxxxxxxxxxx 性质:PDM
1、单项链表如何建立(此题看得明白代码即可,无需写代码)
2、计算函数返回值
int Fun()
{
int count  = 0;
int x = 9999;
while (x)
{
count++;
x = x & (x - 1);
}
return conut;
}
3、文件保存:输入一段整数,要求遇-1结束,并存到“c:\xxxx.dat”
#include<iostream>
#include<fstream>
uisng namespace std;

void main()
{
int i = 0;
ofstream  file(“c:\xxxx.dat”);    //记得成对出现和类名,我当时就写错了
do
       {
cin >> i;
    file << i;
}while (i != -1);
file.close();
}

company 8: xxxxxxxxxxxxxxxxxx 性质:电能测量仪器
1、反转链表
struct test{
int number;
double sort;
test *next;
}

2、联合体和结构体大小
#include <iostream>
#include <string>
using namespace std;




union DATA{
int a[5];
char c;
double d;
};


struct data{
int a;
DATA cow;
char c;
double d;
}too;


DATA MAX;


int main(int arg,char* arc[]){
cout << sizeof(MAX) << endl;
cout << sizeof(data) << endl;
return 0;
}

3、联合体大小
union data{
int a;
char c[2];
}data;

data.c[0] = 10;     //00001010
data.c[1] = 1;       //00000001
data.a = 266;     //100001010


4、class与struct的区别:struct也有构造函数、析构函数、可以继承,也有多态。和class本质区别在与访问权限
#include <iostream>
#include <string>
using namespace std;




struct Base{
int b;
Base(){
cout << "Base gouzao!" << endl;
}
~Base(){
cout << "Base xigou!" << endl;
}
void show(){
cout << "I am Base!" << endl;
};
};


struct A : public Base{
int a;
A(){
cout << "A gouzao!" << endl;
}
~A(){
cout << "A xigou!" << endl;
}
void show(){
cout << "I am A!" << endl;
};
};


int main(int arg,char* arc[]){
A a;
a.show();
return 0;
}

company 9: xxxxxxxxxxxxxxxxxx 性质:上位机串口通信
1、链表反转
2、冒泡排序
3、CMyclass a,b;  //后定义的对象先析构

company 10: xxxxxxxxxxxxxxxxxx 性质:医疗设备
1、动态库与静态库区别
(1)动态库:编译时不链接到目标代码,运行时载入程序。静态库:编译时链接到目标代码,运行时不需要。
2、构造函数与析构函数区别
 (1)相同点:都不能有返回类型。(2)不同点:构造函数有参数类型,可以重载,析构则不能。
3、c与c++区别
 面向过程与面向对象,c++比c多很多东西:模板、引用等


company 11:
1、线程与进程的区别
进程是程序的一次运行,线程是进程执行的代码片段。

2、c++深拷贝与浅拷贝的区别
class A{
private:
int a;
char *b;
public:
A(){
cout << "A 构造" << endl;
}
A(const A &a){
this->a = a.a;
this->b = a.b;   //浅拷贝
//b = new char[strlen(a.b)+1]; //深拷贝
//strcpy(b,a.b);
cout << "A 拷贝构造" << endl;
}
~A(){
//delete[] b;
cout << "A 析构" << endl;
}
};


3、“” 和 <>头文件的区别

当你包含一个头文件时,编译时,需要找到那个头文件,使用<>这种方式,编译器查找的时候,会在编译器的安装目录的标准库中开始查找,""这种方式,会在当前的工程所在的文件夹开始寻找,也就是你的源程序所在的文件夹。
 
4、二分查找
int tFind(int a[],int t,int low,int hight){
	int mid,temp;
	if (low > hight)
		return -1;
	mid = (low + hight) / 2;
	temp = a[mid];
	if(temp == t){
		printf("在位置%d找到%d.\n",mid,t);
		return t;
	}
	if (temp > t){
		return tFind(a,t,low,mid-1);
	}else{
		return tFind(a,t,mid+1,hight);
	}
}


int main ()
{
	int a[] = {0,1,2,3,4,5,6,7,8,9};
	tFind(a,9,0,9);
	return 0;
}

company:12

1、运算符优先级

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;






int main ()
{
int k = 10,j = 10,i = 3;
k *= i + j;
cout << "k=" << k << endl; //130
return 0;

}


company13:

1、比较两个float a,float b的大小:

if(-0.000001 <= a-b && a-b <=0.000001)

 return true;


2、string类的拷贝构造函数、赋值=函数、析构函数

3、写一个日期类

答:注意年月日的输入限制

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值