程序员笔试面试题(2)

2019-05-18 20:17

}

String operator+(const String& a,const String& b){ String temp; temp = a; temp += b; return temp; }

bool operator<(const String& left,const String& right){

int j = 0;

while((left[j] != '\\0') && (right[j] != '\\0')){ if(left[j] < right[j]) return true; else {

if(left[j] == right[j]){ j++;

continue; } else

return false; } }

if((left[j] == '\\0') && (right[j] != '\\0')) return true; else

return false; }

bool operator>(const String& left, const String& right) { int a = strcmp(left.a,right.a); if(a > 0) return true; else

return false; }

istream& operator>>(istream& is, String& s){ delete[] s.a;

s.a = new char[20]; int m = 20; char c; int i = 0;

while (is.get(c) && isspace(c));

if (is) { do {s.a = c; i++;

/*if(i >= 20){

cout << \ exit(-1); }*/

if(i == m - 1 ){ s.a = '\\0';

char* b = new char[m]; strcpy(b,s.a);

m = m * 2; s.a = new char[m]; strcpy(s.a,b); delete[] b; } }

while (is.get(c) && !isspace(c)); //如果读到空白,将其放回. if (is)

is.unget(); }

s.size = i; s.a = '\\0'; return is; }

int main(){

String a = \ String b = \

//String c(6,b);这么写不对. String c(6,'l'); String d;

String e = a;//abcd String f;

cin >> f;//需要输入... String g;

g = a + b;//abcdwww if(a < b)

cout << \ else

cout << \ if(e == a)

cout << \

else

cout << \

b += a;

cout << a << endl; cout << b << endl; cout << c << endl; cout << d << endl; cout << e << endl; cout << f << endl; cout << g << endl; cout << g[0] << endl; return 0; }

4. Implement a single-direction linked list sorting algorithm. Please first define the data structure of linked list and then implement the sorting algorithm.

5.编写一个函数,返回两个字符串的最大公串!例如,“adbccadebbca”和“edabccadece”,返回“ccade”

联想笔试题

1.设计函数 int atoi(char *s)。 int atoi(const char *nptr); 函数说明

atoi()会扫描参数nptr字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再 遇到非数字或字符串结束时('\\0')才结束转换,并将结果返回。 返回值 返回转换后的整型数。 #include #include

int myAtoi(const char* s){ int result = 0; int flag = 1; int i = 0;

while(isspace(s)) i++;

if(s == '-'){ flag = -1; i++; }

if(s == '+')

i++;

while(s != '\\0'){

if((s > '9') || (s < '0')) break; int j = s - '0';

result = 10 * result + j; i++; }

result = result * flag; return result; }

int main(){

char* a = \ -1234def\ char* b = \ int i = myAtoi(a); int j = myAtoi(b); printf(\ printf(\ return 0; }

2.int i=(j=4,k=8,l=16,m=32); printf(“%d”, i); 输出是多少? 3.解释局部变量、全局变量和静态变量的含义。 4.解释堆和栈的区别。

5.论述含参数的宏与函数的优缺点。 普天C++笔试题

1.实现双向链表删除一个节点P,在节点P后插入一个节点,写出这两个函数。 2.写一个函数,将其中的\\t都转换成4个空格。

3.Windows程序的入口是哪里?写出Windows消息机制的流程。 4.如何定义和实现一个类的成员函数为回调函数?

5.C++里面是不是所有的动作都是main()引起的?如果不是,请举例。 6.C++里面如何声明const void f(void)函数为C程序中的库函数? 7.下列哪两个是等同的 int b;

A const int* a = &b; B const* int a = &b;

C const int* const a = &b; D int const* const a = &b;

8.内联函数在编译时是否做参数类型检查? void g(base & b){

b.play; }

void main(){ son s; g(s); return; }

华为笔试题

1.请你分别画出OSI的七层网络结构图和TCP/IP的五层结构图。 2.请你详细地解释一下IP协议的定义,在哪个层上面?主要有什么作用?TCP与UDP呢?

3.请问交换机和路由器各自的实现原理是什么?分别在哪个层次上面实现的? 4.请问C++的类和C里面的struct有什么区别? 5.请讲一讲析构函数和虚函数的用法和作用。

6.全局变量和局部变量有什么区别?是怎么实现的?操作系统和编译器是怎么知道的?

7.8086是多少位的系统?在数据总线上是怎么实现的? Sony笔试题

1.完成下列程序 * *.*. *..*..*.. *...*...*...*...

*....*....*....*....*....

*.....*.....*.....*.....*.....*.....

*......*......*......*......*......*......*......

*.......*.......*.......*.......*.......*.......*.......*....... #include #define N 8 int main() { int i; int j; int k;

--------------------------------------------------------- | | | | | |

--------------------------------------------------------- return 0; }

2.完成程序,实现对数组的降序排序 #include void sort( );


程序员笔试面试题(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:考研英语近义近形词辨析

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: