京东2015校园招聘技术类笔试题(笔试时间:2014-10-18)

笔试时间:2014-10-18
笔试城市:深圳、广州等
笔试职位:技术类(包含各种职位)


答案:

一、1.

A:HTTP协议是无状态的 http协议是无状态的,同一个client的这次请求和上次请求是没有相应关系

B:对的

C:对的

D:http在应用层,TCP udp在第四层传输层

本题:AD

2.

C  0

3.

B  归并排序

4.

B

5.

A

6.

C

7.

A

8.

B

解析:在SQL 语言中,我们能够使用两个通配符:%和_,当中"%"表示0个或多个字符,而"_"则表示一个字符。在本题的查找条件中,要求倒数第三个字母为W,应表示成"W_ _",而且还要求至少包括4个字母,而当以"%"开头时,它表示的字符能够不存在,所以开头应加一个"_",那么查询条件子句应写成WHERE DNAME LIKE′_ % W _ _′。

9.

A

10.

D

举样例:

VS2013下,print语句放入while循环内,断点调试下:

m等于2 ----》打印1

m等于8-----》打印4 2 1

m等于100-----》打印50  25 12 6 3 1

11.

A  true

12.

C

N为1的时候,有两种,排除BD,再举样例就可以。

13.

A 有限状态自己主动

14.

C

若没有static则本题答案是5。

15.

1+2+3+...+20+14=224

224%9 = 8

16.

#include <iostream>
#include <string>
using namespace std;

void RemoveExtraSpaces(string &str)
{
	int numRemoveSpaces = 0;
	bool isSpace = false;
	size_t indexOfStr = 0;
	// 先去掉字符串头的空格
	while (str[indexOfStr] == ' ')
	{
		indexOfStr++;
		numRemoveSpaces++;
	}
	for (;indexOfStr <= str.length(); ++indexOfStr)
	{
		if (str[indexOfStr] == ' ')
		{
			if (isSpace == true)  // str[i-1] == ' '
				numRemoveSpaces++;
			else
			{
				str[indexOfStr - numRemoveSpaces] = str[indexOfStr];
				isSpace = true;
			}
		}
		else
		{
			str[indexOfStr - numRemoveSpaces] = str[indexOfStr];
			isSpace = false;
		}
	}
}


int main(int argc, char* argv[])
{
	string str = "   I am   a     little boy.    ";
	RemoveExtraSpaces(str);
	cout <<str.c_str() <<endl;
	return 0;
}

17.剑指offer上面的最后一个案例。

附加题:

没思路,求大神指导







原文地址:https://www.cnblogs.com/zfyouxi/p/4360653.html