0818面试

 

 

1、

class A{
char a;
double b;
int c;
};
sizeof(A)=?

2、

#define mod(A,B) A%B;
#include<bits/stdc++.h>
using namespace std;
int main(){
    cout<<mod(94,13+4);
}

3、

下列代码中,哪些变量存放于stack中?

 

(代码我不记得了。。)

4、

string str="1234567890",strlen(str)=? sizeof(str)=?

5、

#include<bits/stdc++.h>
using namespace std;
int main(){
    int x=0;
    int a=0,b=1;
    if(!a) x--;
    if(!b) x--; else x++;
    cout<<x<<endl;
}

6、

#include<bits/stdc++.h>
#define mod(A,B) A%B;
using namespace std;
class A{
    public:
    int id;
    static int counter;
    A(){
        cout<<"default\n";
        counter++;
        
    }
    A(int i){
        cout<<"cons\n";
        counter++;
        id=i;
        
    }
    A(const A &b){
        cout<<"copy\n";
        id=b.id;
        counter++;
    }
    A &operator= (const A &b){
        cout<<"operator=\n";
        id=b.id;
        return *this;
    }
    ~A(){
        cout<<"destructor\n";
        counter--;
    }
};
static A sa;
int A::counter=0;
int main(){{
    A a(1);
    A b(2);
    sa=a;
    a=b;
    b=sa;
    A c=a;
    A d(b);
    cout<<"c.id"<<c.id<<endl;
    cout<<"d.id"<<d.id<<endl;
    
}
cout<<"now there're "<<A::counter<<endl;
}

 

7、TCP三次握手链接、四次握手断开的过程?

8、简述Linux进程之间通信的原理

9、写一个队列类,用链表的

10、有m(m>=2)个人围成一圈,传球n(n>=2)次,最后传到第一个人,有多少种方法?

 


 

 

1、24(字节对齐)

2、7(先取余再加)

4、10 11(末尾空字符)

5、0

6、(我差不多写出来了)

 

 7、(我画了这个图,我只写了seq和ack,断开的我写的不准确)

 

 

 9、push有两种情况:

1.空队列

2.多个元素

pop有三种情况:

1.空队列

2.队列只有一个元素

3.队列有不止一个

 

很简单我就不再写了

10、这个要保证最后一个就得保证倒数第二个不是他,又影响倒数第三个我实在没想明白。

 

 

 

哈希表是什么?

红黑树?

STL是什么?

 

posted @ 2020-08-18 21:06  vdk  阅读(127)  评论(0)    收藏  举报