笔试题
tianya_team
关注抖音号:天天coding,免费获得源码以及技术指导。
展开
-
2015百度笔试题(软件)
一、简答题1.请简述TCP-IP3次握手及4次挥手过程。并解释为何关闭连接需要4次挥手。(10分)原创 2016-02-22 17:11:34 · 1159 阅读 · 0 评论 -
C++笔试
1.交换字符串void SwapString(char *&x,char *&y){ char *temp=x; x=y; y=temp;}调用方式:SwapString(a,b);或者void SwapString(char **x,char **y){ char *temp=*x; *x=*y; *y=temp;}调用方式:SwapString(&a,&b)原创 2016-03-14 22:27:35 · 438 阅读 · 0 评论 -
构造函数调用另一个构造函数
#include#include #include #include using namespace std;struct CLS{ int m_i; CLS(int i) :m_i(i){ cout << "CLS(int):this =" << this << endl; } CLS() { CLS(0); //生成一个临时对象,对调用该函数的对象本身没影响原创 2016-03-14 21:42:20 · 586 阅读 · 0 评论 -
京东笔试题
1.8*8的方格,从上往下列的编号 8,7,6,5,4,3,2,1,从左往右的编号a,b,c,d,e,f,g,h。给定起点坐标(a8),后重点坐标(h1),求最大路径。先走对角,在走直线。共八个方向。#include #include #include using namespace std;int min(int a, int b){ return a < b ? a :原创 2016-04-08 22:37:58 · 840 阅读 · 0 评论 -
编写继承类的复制构造函数和构造函数
当基类存在私有成员时,应该如何编写继承类的复制构造函数呢?方法是在复制构造函数的初始化成员列表中调用基类的复制构造函数。class Base{private: int i;public: Base(int _i) :i(_i){}};class Derived:public Base{public: Derived() :Base(0), j(0){} Derived(原创 2016-03-14 21:55:30 · 2992 阅读 · 0 评论 -
atexit()函数(使main函数之后可以执行其他函数)
可以用atexit()函数来注册程序正常终止时要调用的函数,并且在main()函数结束时,调用这些函数的顺序与注册他们的顺序相反。原型:int atexit(void(*)(void));一个程序最多可以注册32个处理函数。#include#include #include using namespace std;void fn1(void);void fn2(void);原创 2016-03-11 23:03:28 · 496 阅读 · 0 评论 -
虚函数里面调用虚函数的输出
class CParent { public: virtual void Intro() { printf( "I'm a Parent, " ); Hobby(); } virtual void Hobby() { printf( "I like football!" ); }}; class CChild :原创 2016-03-13 10:46:58 · 698 阅读 · 0 评论 -
不使用中间变量交换a,b值
void swap(int &a, int &b){ a += b; b = a - b; a = a - b;}void swap1(int &a, int &b){ a ^= b; b ^= a; a ^= b;}原创 2016-03-11 22:54:26 · 325 阅读 · 0 评论 -
::操作全局变量
#include#include #include using namespace std;int value = 0;void printvalue(){ cout << value << endl;}int main() { int value = 0; value = 1; cout << value << endl; ::value = 2; printv原创 2016-03-11 22:45:41 · 273 阅读 · 0 评论 -
虚继承基类构造顺序
#includeusing namespace std;class A{public: A(char *s) { cout << s << endl; } ~A(){}};class B :virtual public A{public: B(char *s1, char*s2) :A(s1){ cout << s2 << endl; }};class C :原创 2016-03-11 10:55:30 · 745 阅读 · 0 评论 -
函数重载
1.int Func(int,int);不可与下列哪个函数构成重载( )A.int Func(int,int,int); B.double Func(int,int);C.double Func(double,double); D.double Func(int,double);答案:B参数类型,数目不同,可以构成重载,返回类型不同不能构成重载。原创 2015-12-23 10:43:18 · 596 阅读 · 0 评论 -
碰到的笔试题
1.将一个从大到小的数组,用以下排列方法排序成从小到大的,()最快。【参考】考察几种排序方法的特征:排序方法 平均情况 最好情况 最坏情况 辅助空间 稳定性冒泡排序 O(n^2) O(n) O(n^2) O(1)原创 2016-10-02 22:34:01 · 327 阅读 · 0 评论