1、我的笔试之一:仟游篇
转自新浪经纬博客
1.输出
char s1[]="2kgames";
char* s2[]={"2kgames" };
char s3[20]="2kgames";
cout< 2、 }
~A(){ p(); }
virtual void p() { q(); }
virtual void q() { cout<<'A'; }
};
class B:public A
{
public:
B() { p(); }
~B() { p(); }
void q() { cout<<'B'; }
};
int main()
{
A* p=new B;
delete p;
}
答案:ABA
3. 用一个C语言表达式判断一个数是否位2的N次幂。
答案:x == (((x ^ 3、~0x0)) + 1) & x)
4. 写一个高性能的函数把一个int乘以9
答案:
int Multiply_9(int a)
{
return ((a<<3)+a);
}
5.请写一个C函数,若处理器是Big_endian的,则返回0;若是Little_endian的,则返回1
解答:
int checkCPU()
{
union w
{
int a;
char b;
} c;
c.a = 1;
return (c.b == 1);
}
6.int (* (*f)(int, int))(i 4、nt)这里的f是什么?
答案:
f是指针,指向一个参数为(int,int),返回值为一个指针的函数
这个返回的指针指向一个参数为(int),返回值为int的函数
我的笔试之二:思科篇
· 1.
typedef struct
{
char data[10];
}T1;
typedef struct
{
T1* p;
char data[0];
}T2;
sizeof(T2)==?
答案:
4
2.含N个元素的一个数组,数组的值的范围是1~N-1,找出重复的那个值。
答案:
int array[N];
int 5、FindRepeat(void)
{
int flag[N]={0};
int i;
for(i=0;i 6、
*((int* const)0x23567890)=5;
}
C char* fuc(void)
{
char a[4];
strcpy(a,"abcd");
return a;
}
答案:
ABC都可以通过编译。
我的笔试之三:趋势科技篇
· 1. 找错误
(1) void Test(const int v)
{
int* p;
p=v;
}
答案:不能把非const指针指向const变量。应该是:const int* p;
7、
(2) void Test(const int& v)
{
const int& p;
p=v;
}
答案:引用必须在定义的时候初始化。应该是:const int& p=v;
2. 编程题,翻转链表。
答案:
typedef struct node
{
int value;
struct node* next;
}SLink;
SLink* ReverseLink(SLink* h)
{
SLink* pre,*cur,*next;
pre=NULL;
cur=h;
8、 next=cur->next;
while(next)
{
cur->next=pre;
pre=cur;
cur=next;
next=next->next;
}
return cur;
}
3.写出输出结果
class A
{
public:
A() { f(0); }
virtual void f(int n)
{
cout<<"A0:"< 9、virtual void f(char* s)
{
cout<<"A2:"< 10、 A().f(2);
cp=&b;
cp->f(2);
}
答案:
A0:0
B0:1
B1:test
A0:0
A0:2
A1:2
4. UTP(非屏蔽双绞线)的传输距离是?
答案:100m
5.176.68.160.0/22的子网掩码是:
答案:255.255.252.0
我的笔试之四:先锋商泰篇
1.下面表达式正确的是:
A. char* const s="hello";
*s='w';
B. char* const s="hello";
s="world";
C. const 11、 char* s="hello";
*s='w';
D. const char* s="hello";
s="world";
答案:D
2.下面表达式正确的是:
A. char* const s="hello";
*s='w';
B. char* const s="hello";
s="world";
C. char s[]="hello";
*s='w';
D. char s[]="hello";
s="world";
答案:C
3.写出程序输出结果:
char t[]="abcdefghijkl 12、mno";
t[12]='\0';
int i=0;
while(t[++i]!='\0')
{
printf("%c",t[i++]);
}
答案:bdfhjln
我的笔试之五--展讯篇
1. 编程求两个字符串的最大公共字符串。
答案:
· #include "stdio.h"
#include "string.h"
/* 函数功能:求两个字符串的最大公共字符串 */
void CommonStr(char* str1,char* str2)
{
char* s1,*s2;
int i,j,k; // 13、 i--最大公共字符串的长度
int len1; // j--子串s2的开始位置
int len2; // k--子串s1的开始位置
int p;
len1=strlen(str1);
len2=strlen(str2);
if(len1 14、n2;j++)
{
for(k=0;k+i<=len1;k++)
{
p=0;
while(s1[k+p]==s2[j+p])
{
p++;
}
if(p>=i)
{
for(p=0;p
f(1);
p->f("test");






