**************************************
*************************************
软件笔试.doc (956 KB)
**************************************
**************************************
1.多态类中的虚函数表是Compile-Time,还是Run-Time时建立的?
2.将一个 1M -10M 的文件,逆序存储到另一个文件,就是前一个文件的最后一个
字符存到新文件的第一个字符,以此类推。
3.main主函数执行完毕后,是否可能会再执行一段代码?
4.一个父类写了一个virtual 函数,如果子类覆盖它的函数不加virtual ,也能实现多态?
在子类的空间里,有没有父类的这个函数,或者父类的私有变量?
5.给一个字符串、例如 “ababc”要求返回“ab”. 因为“ab”连续重复出现且最长。
用C/C++语言写一函数完成该算法,给出复杂度
6.对序列1、1、2、3、5、8、13。。。。 是Fab..数列
2、3、5、13...是Fab..质数数列,因为他们与自己前面的Fab...数列都互质
给出k,返回第k小的Fab..质数
7.101个硬币100真、1假,真假区别在于重量。请用无砝码天平称两次给出真币重还是假币
重的结论。
8.完成字符串拷贝可以使用 sprintf、strcpy 及 memcpy 函数,请问这些函数有什么区别
,你喜欢使用哪个,为什么?
9.变量的声明和定义有什么区别?
10.请写出下面代码在 32 位平台上的运行结果,并说明 sizeof 的性质:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char a[30];
char *b = (char *)malloc(20 * sizeof(char));
printf("%d\n", sizeof(a));
printf("%d\n", sizeof(b));
printf("%d\n", sizeof(a[3]));
printf("%d\n", sizeof(b+3));
printf("%d\n", sizeof(*(b+4)));
return 0 ;
}
12.请完成以下题目。注意,请勿直接调用 ANSI C 函数库中的函数实现。
a)请编写一个 C 函数,该函数给出一个字节中被置 1 的位的个数,并请
给出该题的至少一个不同解法。
b)请编写一个 C 函数,该函数将给定的一个字符串转换成整数。
c)请编写一个 C 函数,该函数将给定的一个整数转换成字符串。
d)请编写一个 C 函数,该函数将一个字符串逆序。
e)请编写一个 C 函数,该函数在给定的内存区域搜索给定的字符,并返回
该字符所在位置索引值。
f)请编写一个 C 函数,该函数在一个字符串中找到可能的最长的子字符串,
该字符串是由同一字符组成的。
给出演示上述函数功能的一个简单程序,并请编写对应的 Makefile 文件
13.我们需要编写一个图形相关的应用程序,需要处理大量图形(Shape)信息,
图形有矩形(Rectangle),正方形(Square),圆形 (Circle)等种类,应用
需要计算这些图形的面积,并且可能需要在某个设备上进行显示(使用在标准
输出上打印信息的方式做为示意)。
a)请用面向对象的方法对以上应用进行设计,编写可能需要的类
b)请给出实现以上应用功能的示例性代码,从某处获取图形信息,
并且进行计算和绘制
c)如果你的Square继承自Rectangle,请给出理由,如果不是,
请给出理由,并且请比较两种方式的优劣
d)请问你所编写的类,在如下代码中会有何表现,请解释
void test_rectangle_area(Rectangle& r)
{
r.set_width(10);
r.set_height(15);
assert(r.area() == 150);
}
14.假设现有一个单向的链表,但是只知道只有一个指向该节点的指针p,并且假设这个节
点不是尾节点,试编程实现删除此节点
15.写一个程序,把一个100以内的自然数分解因数。(自然数分解因数就是将一个自然数
分解为几个素数的乘积,提示,由于该数不是很大,所以可以将质数保存在数组中,以加快计
算速度)
16.编写一个Identify的分配、释放的函数,为1-10000之间的自然数。
17.分别实现itoa和atoi.
18.Consider the following code:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
int i = 1;
char buf[4];
strcpy(buf, "AAAA");
printf("%d\n", i);
return 0;
}
a) When compiled and executed on x86, why does this program usually not
output what the programmer intended?
b) Name several ways in which the security problem that causes this
program not to output what the programmer intended can be prevented
WITHOUT changing the code.
19.int w=1,x=2,y=3,z=4;
m=(w<x)?w:x;
m=(m<y)?m:y;
m=(m<2)?m:z;
printf("m=%d",m); 说出结果
20.说出结果
#include <stdio.h>
main()
{
FILE *fp;
int i,a[4]={1,2,3,4},b;
fp=fopen("data.dat","wb");//这里帮忙解释一下
for(i=0;i<4;i++)
fwrite(&a[i],sizeof(int),1,fp);//这里也帮忙看一下
fclose(fp);
fp=fopen("data.dat","rb");
fseek(fp,-2L*sizeof(int),SEEK_END);//还有这里
fread(&b,sizeof(int),1,fp);//这里还有也看一下
fclose(fp);
printf("b=%d\n",b);
}
21.有双向循环链表结点:
typedef struct node
{
int date;
struct node *front,*next;
}_Node;
有两个双向循环链表A,B,知道其头指针为:pHeadA,pHeadB,请写一函数将两上链表中d
ate值相同的结点删除
22.
char * GetStr()
{
char *tmp;
tmp = "123"
return tmp;
}
void main()
{
printf("%s", GetStr());
}
会输出123吗?123创建在堆上还是栈上呢?123的空间是什么时候释放的?
23.
字符指针、浮点数指针、以及函数指针这三种类型的变量哪个占用的内存最大?为什么?
类ClassB从ClassA派生,那么ClassA *a = new ClassB(…); 试问该表达是否合法?为什
么?
如果ClassA中定义并实现虚函数int func(void),ClassB中也实现该函数,那么上述变量
a->func()将调用哪个类里面的函数?如果int func(void)不是虚函数,情况又如何?为什
么?
char **p, a[16][8]; 问:p=a是否会导致程序在以后出现问题?为什么?
如下所述的if else和switch语句哪个的效率高?为什么?
在同一个进程中,一个模块是否可以通过指针操作破坏其它模块的内存,为什么?
应用程序在运行时的内存包括代码区和数据区,其中数据区又包括哪些部分?
24.Assignment 2: Picture Processing
Use C++, Java, or similar languages or/and any middleware such as EJB and J2EE
to process a picture with a high resolution (3 Mega Pixels for example). Use
some methodologies to degrade the resolution of the picture to make it quick
er for browsing. Then divide the degraded picture into 9 sectors equally. Cli
ck any of the 9 sectors will result a detailed picture for this sector with t
he same resolution as that of the original picture. This assignment is design
ed for you to demonstrate your ability to handle pictures.
25.用<<,>>,|,&实现一个WORD(2个字节)的高低位交换!!
26.要开辟P1,P2,P3,P4内存来做缓冲,大小自定,但这四个缓冲的大小要一样,并且是连续的
!
27.有一浮点型数组A,用C语言写一函数实现对浮点数组A进行降序排序,并输出结果,要求要
以数组A作为函数的入口.(建议用冒泡排序法)
28.找错:
#include <string.h>
#include <stdio.h>
class Base
{
private:
char * name;
public:
Base(char * className)
{
name = new char[strlen(className)];
strcpy(name, className);
}
~Base()
{
delete name;
}
char * copyName()
{
char newname [256];
strcpy(newname, name);
return newname;
}
char * getName()
{
return name;
}
static void print(Base base)
{
printf("name: %s\n" , base.name);
}
};
class Subclass : public Base
{
public:
Subclass(char * className) : Base(className)
{
}
};
int main()
{
Base * pBase = new Subclass("test");
Base::print(*pBase);
printf("name: %s\n", pBase->getName());
printf("new name: %s\n", pBase->copyName());
return 0;
}
29.编写一个函数,函数接收一个字符串,是由十六进制数组成的一组字符串,函数的功能是
把接到的这组字符串转换成十进制数字.并将十进制数字返回.
30.编写一个函数将一条字符串分成两部分,将前半部分按ASCII码升序排序,后半部分不
变,(如果字符串是奇数则中间的字符不变,)最后再将前后两部分交换,然后将该字符
串输出,
测试字符串“ADZDDJKJFIEJHGI”
31.找错
Void test1()
{
char string[10];
char* str1="0123456789";
strcpy(string, str1);
}
Void test2()
{
char string[10], str1[10];
for(I=0; I<10;I++)
{
str1[i] ='a';
}
strcpy(string, str1);
}
Void test3(char* str1)
{
char string[10];
if(strlen(str1)<=10)
{
strcpy(string, str1);
}
}
32. 找错
#define MAX_SRM 256
DSN get_SRM_no()
{
static int SRM_no;
int I;
for(I=0;I{
SRM_no %= MAX_SRM;
if(MY_SRM.state==IDLE)
{
break;
}
}
if(I>=MAX_SRM)
return (NULL_SRM);
else
return SRM_no;
}
33. 写出程序运行结果
int sum(int a)
{
auto int c=0;
static int b=3;
c+=1;
b+=2;
return(a+b+C);
}
void main()
{
int I;
int a=2;
for(I=0;I<5;I++)
{
printf("%d,", sum(a));
}
}
34.
int func(int a)
{
int b;
switch(a)
{
case 1: 30;
case 2: 20;
case 3: 16;
default: 0
}
return b;
}
则func(1)=?
35:
int a[3];
a[0]=0; a[1]=1; a[2]=2;
int *p, *q;
p=a;
q=&a[2];
则a[q-p]=?
36.
定义 int **a[3][4], 则变量占有的内存空间为:_____
37.
编写一个函数,要求输入年月日时分秒,输出该年月日时分秒的下一秒。如输入2004年12
月31日23时59分59秒,则输出2005年1月1日0时0分0秒。
38.写一个函数,判断一个int型的整数是否是2的幂,即是否可以表示成2^X的形式(不可
以用循环)
我只知道是用递推,大概写了一下,如下:
int IsTwoPow(int s)
{
if(s==1)return FALSE;
s=s>>1;
if(s>1)IsTwoPow(s);
return (s==1)?TRUE:FALSE;//大概是这个意思,但是这一句似乎不该这么返回!
}
39 A,B从一堆玻璃球(共100个)里向外拿球,规则如下:
(1)A先拿,然后一人一次交替着拿;
(2)每次只能拿1个或2个或4个;
(3)谁拿最后一个球,谁就是最后的失败者;
问A,B谁将是失败者?写出你的判断步骤。
40.已知:无序数组,折半查找,各元素值唯一。
函数原型是:Binary_Seach(int array[], int iValue, int iCount)
array是数组,在里面用折半查找的方法找等于iValue的值,找到返回1否则0,iCount是元
素个数
41.统计一个字符串中字符出现的次数
42.100位以上的超大整数的加法(主要考虑数据结构和加法的实现)。
43.对如下电文:"CASTCASTSATATATASA"给出Huffman编码。
44.int (* (*f)(int, int))(int)表示什么含义?
45.x=x+1,x+=1,x++,为这三个语句的效率排序。并说明为什么。
46.中缀表达式 A-(B+C/D)*E的后缀形式是什么?
47.struct S1
{
char c;
int i;
};
sizeof(S1) = ?
class X{
public:
X();
virtual ~X();
void myMemberFunc();
static void myStaticFunc();
virtual void myVirtualFunc();
private:
int i;
char * pstr;
char a;
}
sizeof(X) = ?
48.找出两个字符串中最大子字符串,如"abractyeyt","dgdsaeactyey"的最大子串为"acty
et"
49.有一百个整数,其中有负数,找出连续三个数之和最大的部分.
50.写一程序实现快速排序. 假设数据输入为一文件
快速算法描述如下
Algorithm Partition
Input: sequence a0, ..., an-1 with n elements
Output: permutation of the sequence such that all elements a0, ..., aj are les
s than or equal to all
elements ai, ..., an-1 (i > j)
Method:
choose the element in the middle of the sequence as comparison element x
let i = 0 and j = n-1
while ij
search the first element ai which is greater than or equal to x
search the last element aj which is less than or equal to x
if ij
exchange ai and aj
let i = i+1 and j = j-1
After partitioning the sequence, Quicksort treats the two parts recursively by
the same procedure.
The recursion ends whenever a part consists of one element only.
51.写一算法检测单向链表中是否存在环(whether there is a loop in a link list),
要求算法复杂度(Algorithm's complexity是O(n)) 并只使用常数空间(space is O(c)).
注意,你只知道一个指向单向链表头的指针。链表的长度是不定的,而且环出现的地方也
是不定的,环有可能在头,有可能在中间。而且要求是检测, 不能破坏环的结构.
52.设下列函数已经通过了调试
bool Sort_Array(ArrayType * Pinputarray, ArrayType * Poutarray);
该函数在内存中排序,能把字节数最大为100M字节的ArrayType类型的数组排序。其中Arr
ayType是一个
预定义的数组类型(细节无关紧要),Pinputarray,Poutarray分别为排序前的指针和排
序后的指针。
请用c语言的伪码风格设计一个算法,他调用上面给出的函数完成下列从输入到输出的任务
:
输入:排序前的大文件,名称为char * pinoutfilename ,其内容为用分号分隔的ArrayT
ype类型的数组元素,可装满4个100M字节的数组。
输出:排序后的大文件char * poutoutfilename。
53.用最有效率的方法算出2乘以8等於几?
54.
1.错误的转义字符是 (c )
A.'\091' B.'\\'
C.'\0' D.'\''
2.若数组名作实参而指针变量作形参,函数调用实参传给形参的是 (d )
A.数组的长度 B.数组第一个元素的值
C.数组所有元素的值 D.数组第一个元素的地址
3.变量的指针含意是指变量的 (b )
A.值 B.地址
C.存储 D.名字
5.某文件中定义的静态全局变量(或称静态外部变量)其作用域是 (d )
A.只限某个函数 B.本文件
C.跨文件 D.不限制作用域
55.
1. 解二次方程:a*x*x+b*x+c
int Quadratic( double a,double b,double c,double& x1,double& x2);
返回值:解的个数
2. 最大公约数
DWORD Divisor( DWORD dwFirst, DWORD dwSecond );
返回值:最大公约数
3. 根据蒙特卡洛算法计算圆周率
double PI( DOWRD dwCount/*测试次数*/ );
返回值:PI
4. 无符号整数乘法,乘数为32bit,结果为64bit
提示:32bit整数分解为16bit相乘
void Multiply( DWORD dwFirst, DWORD dwSecond, DWORD& dwHigh, DWORD& dwLower );
5. 链表排序(从小到大)
节点定义为:
struct Node{
int nValue;
struct Node* pNext;
};
最后一个节点的pNext = NULL.
Node* SortChain( Node* pHead );
返回值:链表头
改错并说明原因
file: 1.c
int a[10]={0};
file: 2.c
int
main ()
{
extern int *a;
printf ("%d\n", a[0]);
return 0;
}
1 #include “filename.h”和#include <filename.h>的区别?
对于#i nclude <filename.h>编译器从标准库开始搜索filename.h;对于#i nclude “filename.h”编译器从用户工作路径开始搜索filename.h
2 头文件的作用是什么?
一、通过头文件来调用库功能。在很多场合,源代码不便(或不准)向用户公布,只要向用户提供头文件和二进制的库即可。用户只需要按照头文件中的接口声明来调用库功能,而不必关心接口怎么实现的。编译器会从库中提取相应的代码。二、头文件能加强类型安全检查。如果某个接口被实现或被使用时,其方式与头文件中的声明不一致,编译器就会指出错误,这一简单的规则能大大减轻程序员调试、改错的负担。
3 C++函数中值的传递方式有哪几种?
C++函数的三种传递方式为:值传递、指针传递和引用传递。
4 内存的分配方式的分配方式有几种?
答:一、从静态存储区域分配。内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在。例如全局变量。
二、在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集中,效率很高,但是分配的内存容量有限。
三、从堆上分配,亦称动态内存分配。程序在运行的时候用malloc或new申请任意多少的内存,程序员自己负责在何时用free或delete释放内存。动态内存的生存期由我们决定,使用非常灵活,但问题也最多。
5 实现双向链表删除一个节点P,在节点P后插入一个节点,写出这两个函数;
6 写一个函数,将其中的\t都转换成4个空格。
7 Windows程序的入口是哪里?写出Windows消息机制的流程.
8 如何定义和实现一个类的成员函数为回调函数?
9 C++里面是不是所有的动作都是main()引起的?如果不是,请举例.
10 C++里面如何声明const void f(void)函数为C程序中的库函数
11 下列哪两个是等同的
int b;
A const int* a = &b;
B const* int a = &b;
C const int* const a = &b;
D int const* const a = &b;
12 内联函数在编译时是否做参数类型检查
13 三个float:a,b,c
问值
(a+b)+c==(b+a)+c
(a+b)+c==(a+c)+b
14 把一个链表反向填空
15 设计一个重采样系统,说明如何anti-alias
16 某个程序在一个嵌入式系统(200M的CPU,50M的SDRAM)中已经最化了,换到另一个系统(
300M的CPU,50M的SDRAM)中运行,还需要优化吗?
17. 下面哪种排序法对12354最快
a quick sort
b.buble sort
c.merge sort
18. 哪种结构,平均来讲,获取一个值最快
a. binary tree
b. hash table
c. stack
19 请问C++的类和C里面的struct有什么区别?
20 请讲一讲析构函数和虚函数的用法和作用?
21 全局变量和局部变量有什么区别?实怎么实现的?操作系统和编译器是怎么知道的?
22 一些寄存器的题目,主要是寻址和内存管理等一些知识。
23 8086是多少位的系统?在数据总线上是怎么实现的?
24 多态。overload 和 override的区别。
重载Overload特点(两必须一可以)
public bool withdraw(double amt, string name)
public double withdraw(double amt)
1、方法名必须相同
2、参数列表必须不相同
3、返回值类型可以不相同
注意:override存在于继继承的关系类中。
覆写Override特点(三相同):
public override bool withdraw(...)
1、方法名相同
2、参数列表相同
3、返回值类型相同
注意:存在于同一类中,但是只有虚方法和抽象方法才能被覆写.
<<Sony笔试题>>
25.完成下列程序
*
*.*.
*..*..*..
*...*...*...*...
*....*....*....*....*....
*.....*.....*.....*.....*.....*.....
*......*......*......*......*......*......*......
*.......*.......*.......*.......*.......*.......*.......*.......
#include <stdio.h>
#define N 8
int main()
{
int i;
int j;
int k;
---------------------------------------------------------
| |
| |
| |
---------------------------------------------------------
return 0;
}
26 完成程序,实现对数组的降序排序
#include <stdio.h>
void sort( );
int main()
{
int array[]={45,56,76,234,1,34,23,2,3}; //数字任//意给出
sort( );
return 0;
}
void sort( )
{
____________________________________
| |
| |
|-----------------------------------------------------|
}
27 费波那其数列,1,1,2,3,5……编写程序求第十项。可以用递归,也可以用其他方
法,但要说明你选择的理由。
#include <stdio.h>
int Pheponatch(int);
int main()
{
printf("The 10th is %d",Pheponatch(10));
return 0;
}
int Pheponatch(int N)
{
--------------------------------
| |
| |
--------------------------------
}
28 下列程序运行时会崩溃,请找出错误并改正,并且说明原因。
#include <stdio.h>
#include <malloc.h>
typedef struct{
TNode* left;
TNode* right;
int value;
} TNode;
TNode* root=NULL;
void append(int N);
int main()
{
append(63);
append(45);
append(32);
append(77);
append(96);
append(21);
append(17); // Again, 数字任意给出
}
void append(int N)
{
TNode* NewNode=(TNode *)malloc(sizeof(TNode));
NewNode->value=N;
if(root==NULL)
{
root=NewNode;
return;
}
else
{
TNode* temp;
temp=root;
while((N>=temp.value && temp.left!=NULL) || (N<temp. value && temp. right!=
NULL
))
{
while(N>=temp.value && temp.left!=NULL)
temp=temp.left;
while(N<temp.value && temp.right!=NULL)
temp=temp.right;
}
if(N>=temp.value)
temp.left=NewNode;
else
temp.right=NewNode;
return;
}
}
29. A class B network on the internet has a subnet mask of 255.255.240.0, what
is the maximum number of hosts per subnet .
a. 240 b. 255 c. 4094 d. 6553
4
30. What is the difference: between o(log n) and o(log n^2), where both logari
thems have base 2 .
a. o(log n^2) is bigger b. o(log n) is bigger
c. no difference
31. For a class what would happen if we call a class’s constructor from with
the same class’s constructor .
a. compilation error b. linking error
c. stack overflow d. none of the above
32. “new” in c++ is a: .
a. library function like malloc in c
b. key word c. operator
d. none of the above
33. Which of the following information is not contained in an inode .
a. file owner b. file size
c. file name d. disk address
34. What’s the number of comparisons in the worst case to merge two sorted li
sts containing n elements each .
a. 2n b.2n-1 c.2n+1 d.2n-2
35. Time complexity of n algorithm T(n), where n is the input size ,is T(n)=T(
n-1)+1/n if n>1 otherwise 1 the order of this algorithm is .
a. log (n) b. n c. n^2 d. n^n
36. The number of 1’s in the binary representation of 3*4096+ 15*256+5*16+3 a
re .
a. 8 b. 9 c. 10 d. 12
37.设计函数 int atoi(char *s)。
38.int i=(j=4,k=8,l=16,m=32); printf(“%d”, i); 输出是多少?
39.解释局部变量、全局变量和静态变量的含义。
40.解释堆和栈的区别。
41.论述含参数的宏与函数的优缺点。
42. 以下三条输出语句分别输出什么?[C易]
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?
cout << boolalpha << ( str3==str4 ) << endl; // 输出什么?
cout << boolalpha << ( str5==str6 ) << endl; // 输出什么?
答:分别输出false,false,true。str1和str2都是字符数组,每个都有其自己的存储区,它们的值则是各存储区首地址,不等;str3和str4同上,只是按const语义,它们所指向的数据区不能修改。str5和str6并非数组而是字符指针,并不分配存储区,其后的“abc”以常量形式存于静态数据区,而它们自己仅是指向该区首地址的指针,相等。
43. 非C++内建型别 A 和 B,在哪几种情况下B能隐式转化为A?[C++中等]
答:
a. class B : public A { ……} // B公有继承自A,可以是间接继承的
b. class B { operator A( ); } // B实现了隐式转化为A的转化
c. class A { A( const B& ); } // A实现了non-explicit的参数为B(可以有其他带默认值的参数)构造函数
d. A& operator= ( const A& ); // 赋值操作,虽不是正宗的隐式类型转换,但也可以勉强算一个
44. 以下代码中的两个sizeof用法有问题吗?[C易]
void UpperCase( char str[] ) // 将 str 中的小写字母转换成大写字母
{
for( size_t i=0; i<sizeof(str)/sizeof(str[0]); ++i )
if( 'a'<=str[i] && str[i]<='z' )
str[i] -= ('a'-'A' );
}
char str[] = "aBcDe";
cout << "str字符长度为: " << sizeof(str)/sizeof(str[0]) << endl;
UpperCase( str );
cout << str << endl;
答:函数内的sizeof有问题。根据语法,sizeof如用于数组,只能测出静态数组的大小,无法检测动态分配的或外部数组大小。函数外的str是一个静态定义的数组,因此其大小为6,函数内的str实际只是一个指向字符串的指针,没有任何额外的与数组相关的信息,因此sizeof作用于上只将其当指针看,一个指针为4个字节,因此返回4。
45. 以下代码有什么问题?[C难]
void char2Hex( char c ) // 将字符以16进制表示
{
char ch = c/0x10 + '0'; if( ch > '9' ) ch += ('A'-'9'-1);
char cl = c%0x10 + '0'; if( cl > '9' ) cl += ('A'-'9'-1);
cout << ch << cl << ' ';
}
char str[] = "I love 中国";
for( size_t i=0; i<strlen(str); ++i )
char2Hex( str[i] );
cout << endl;
46. 以下代码有什么问题?[C++易]
struct Test
{
Test( int ) {}
Test() {}
void fun() {}
};
void main( void )
{
Test a(1);
a.fun();
Test b();
b.fun();
}
答:变量b定义出错。按默认构造函数定义对象,不需要加括号。
47. 以下代码有什么问题?[C++易]
cout << (true?1:"1") << endl;
答:三元表达式“?:”问号后面的两个操作数必须为同一类型。
8. 以下代码能够编译通过吗,为什么?[C++易]
unsigned int const size1 = 2;
char str1[ size1 ];
unsigned int temp = 0;
cin >> temp;
unsigned int const size2 = temp;
char str2[ size2 ];
答:str2定义出错,size2非编译器期间常量,而数组定义要求长度必须为编译期常量。
48. 以下代码中的输出语句输出0吗,为什么?[C++易]
struct CLS
{
int m_i;
CLS( int i ) : m_i(i) {}
CLS()
{
CLS(0);
}
};
CLS obj;
cout << obj.m_i << endl;
答:不能。在默认构造函数内部再调用带参的构造函数属用户行为而非编译器行为,亦即仅执行函数调用,而不会执行其后的初始化表达式。只有在生成对象时,初始化表达式才会随相应的构造函数一起调用。
49. C++中的空类,默认产生哪些类成员函数?[C++易]
答:
class Empty
{
public:
Empty(); // 缺省构造函数
Empty( const Empty& ); // 拷贝构造函数
~Empty(); // 析构函数
Empty& operator=( const Empty& ); // 赋值运算符
Empty* operator&(); // 取址运算符
const Empty* operator&() const; // 取址运算符 const
};
50. 以下两条输出语句分别输出什么?[C++难]
float a = 1.0f;
cout << (int)a << endl;
cout << (int&)a << endl;
cout << boolalpha << ( (int)a == (int&)a ) << endl; // 输出什么?
float b = 0.0f;
cout << (int)b << endl;
cout << (int&)b << endl;
cout << boolalpha << ( (int)b == (int&)b ) << endl; // 输出什么
51. 以下反向遍历array数组的方法有什么错误?[STL易]
vector array;
array.push_back( 1 );
array.push_back( 2 );
array.push_back( 3 );
for( vector::size_type i=array.size()-1; i>=0; --i ) // 反向遍历array数组
{
cout << array[i] << endl;
}
答:首先数组定义有误,应加上类型参数:vector<int> array。其次vector::size_type被定义为unsigned int,即无符号数,这样做为循环变量的i为0时再减1就会变成最大的整数,导致循环失去控制。
52. 以下代码有什么问题?[STL易]
typedef vector IntArray;
IntArray array;
array.push_back( 1 );
array.push_back( 2 );
array.push_back( 2 );
array.push_back( 3 );
// 删除array数组中所有的2
for( IntArray::iterator itor=array.begin(); itor!=array.end(); ++itor )
{
if( 2 == *itor ) array.erase( itor );
}
答:同样有缺少类型参数的问题。另外,每次调用“array.erase( itor );”,被删除元素之后的内容会自动往前移,导致迭代漏项,应在删除一项后使itor--,使之从已经前移的下一个元素起继续遍历。
53. 写一个函数,完成内存之间的拷贝。[考虑问题是否全面]
答:
void* mymemcpy( void *dest, const void *src, size_t count )
{
char* pdest = static_cast<char*>( dest );
const char* psrc = static_cast<const char*>( src );
if( pdest>psrc && pdest<psrc+cout ) 能考虑到这种情况就行了
{
for( size_t i=count-1; i!=-1; --i )
pdest[i] = psrc[i];
}
else
{
for( size_t i=0; i<count; ++i )
pdest[i] = psrc[i];
}
return dest;
}
int main( void )
{
char str[] = "0123456789";
mymemcpy( str+1, str+0, 9 );
cout << str << endl;
system( "Pause" );
return 0;
}
54 线程与进程的区别
55:请你分别划划OSI的七层网络结构图,和TCP/IP的五层结构图?
56:请你详细的解释一下IP协议的定义,在哪个层上面,主要有什么作用? TCP与UDP呢?
57:请问交换机和路由器分别的实现原理是什么?分别在哪个层次上面实现的?
58:请问C++的类和C里面的struct有什么区别?
59:请讲一讲析构函数和虚函数的用法和作用?
60:全局变量和局部变量有什么区别?实怎么实现的?操作系统和编译器是怎么知道的?
61:一些寄存器的题目,主要是寻址和内存管理等一些知识。
62:8086是多少位的系统?在数据总线上是怎么实现的?
<<IBM>>
63.怎样用最快的方法判断链表是否有环?
64.c++中引用和指针有什么不同?指针加上什么限制等于引用?
65.做的项目,遇到的困难,怎样解决?
66.在房里有三盏灯,房外有三个开关,在房外看不见房内的情况,你只能进门一次,你用什么
方法来区分那个开关控制那一盏灯.
67.有两根不均匀分布的香,每根香烧完的时间是一个小时,你能用什么方法来确定一段15分
钟的时间.
68.一个经理有三个女儿,三个女儿的年龄加起来等于13,三个女儿的年龄乘起来等于经理自
己的年龄,有一个下属已知道经理的年龄,但仍不能确定经理三个女儿的年龄,这时经理说只
有一个女儿的头发是黑的,然后这个下属就知道了经理三个女儿的年龄.请问三个女儿的年
龄分别是多少?为什么?
69.操作符重载
class CMyObject:pulic CObject
{
Public:
CMyObject();
CMyObject &operator=(const CMyObject &my);
private:
CString strName;
int nId:
};
请重载赋值操作符
70.链表
Struct structList
{
int value;
structList *pHead;
}
Struct LinkedList *pMyList;
请编写删除链表的头、尾和第n个节点的程序
71.用Socket API制作一个聊天程序,通讯协议使用tcp/ip。要求有简单界面即可,支持多
人聊天。
72.如果有过工作经验,请说明在先前公司的工作以及离职原因(如无,请说明毕业后的个
人展望)
***************************************************************************
73 对于C++中类(class) 与结构(struct)的描述正确的为:
A,类中的成员默认是private的,当是可以声明为public,private 和protected,结构中定
义的成员默认的都是public;
B,结构中不允许定义成员函数,当是类中可以定义成员函数;
C,结构实例使用malloc() 动态创建,类对象使用new 操作符动态分配内存;
D,结构和类对象都必须使用new 创建;
E,结构中不可以定义虚函数,当是类中可以定义虚函数.
F,结构不可以存在继承关系,当是类可以存在继承关系.
答:A,D,F
***************************************************************************
***************************************************************************
74,两个互相独立的类:ClassA 和 ClassB,都各自定义了非景泰的公有成员函数 PublicFu
nc() 和非静态的私有成员函数 PrivateFunc();
现在要在ClassA 中增加定义一个成员函数ClassA::AdditionalPunction(ClassA a,Cl
assB b);则可以在AdditionalPunction(ClassA x,ClassB y)的实现部分(函数功能体内部
)
出现的合法的表达是最全的是:
A,x.PrivateFunc();x.PublicFunc();y.PrivateFunc();y.PublicFunc();
B,x.PrivateFunc();x.PublicFunc();y.PublicFunc();
C,x.PrivateFunc();y.PrivateFunc();y.PublicFunc();
D,x.PublicFunc();y.PublicFunc();
答:B
***************************************************************************
***************************************************************************
75,C++程序下列说法正确的有:
A,对调用的虚函数和模板类都进行迟后编译.
B,基类与子类中函数如果要构成虚函数,除了要求在基类中用virtual 声名,而且必须名
字相同且参数类型相同返回类型相同
C,重载的类成员函数都必须要:或者返回类型不同,或者参数数目不同,或者参数序列的类
型不同.
D,静态成员函数和内联函数不能是虚函数,友员函数和构造函数也不能是虚函数,但是析
构函数可以是虚函数.
答:A
***************************************************************************
76,C++中的类与结构的区别?
77,构造函数和析构函数是否可以被重载,为什么?
78,一个类的构造函数和析构函数什么时候被调用,是否需要手工调用?
热忱期待高手的答案,我不怕丑!一天做几个,把答案贴出来,请高手指正!
1 #include “filename.h”和#include <filename.h>的区别?
答:#include “filename.h”表明该文件是用户提供的头文件,查找该文件时从当前文件
目录开始;#include <filename.h>表明这个文件是一个工程或标准头文件,查找过程会检
查预定义的目录。
2 头文件的作用是什么?
答:一、通过头文件来调用库功能。在很多场合,源代码不便(或不准)向用户公布,只
要向用户提供头文件和二进制的库即可。用户只需要按照头文件中的接口声明来调用库功
能,而不必关心接口怎么实现的。编译器会从库中提取相应的代码。
二、头文件能加强类型安全检查。如果某个接口被实现或被使用时,其方式与头文件中的
声明不一致,编译器就会指出错误,这一简单的规则能大大减轻程序员调试、改错的负担
。
3 C++函数中值的传递方式有哪几种?
答:C++函数的三种传递方式为:值传递、指针传递和引用传递。
4 内存的分配方式的分配方式有几种?
答:一、从静态存储区域分配。内存在程序编译的时候就已经分配好,这块内存在程序的
整个运行期间都存在。例如全局变量。
二、在栈上创建。在执行函数时,函数内局部变量的存储单元都可以在栈上创建,函数执
行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集中,效率很高
,但是分配的内存容量有限。
三、从堆上分配,亦称动态内存分配。程序在运行的时候用malloc或new申请任意多少的内存,程序员自己负责在何时用free或delete释放内存。动态内存的生存期由我们决定,使用非常灵活,但问题也最多。
交换两个数,不用第三块儿内存!请问怎么实现?
现有12个小球,其中只有1个球与其它的球重量不同(即有11个球重量全相同),并且不知道这
个跟其它球重量不同的球是重还是轻(跟其他11个重量相同的球相比而言),那么从这12个球
中找出这个跟其它球重量不同的球.
北电
昨天笔试共5道题目:
1.英译汉 ,关于ITU和CCITT的
2.汉译英,关于VMware的
3.两个有序数组的合并,写一个完整的程序
4.填空题,排序二叉树节点的删除,5个空
5.调试题,多线程文件的读写,编译没有错误,请找出至少三个bug.
翻译只占10分,后面三道每道30
实现双向链表删除一个节点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,程序设计(可以用自然语言来描述,不编程):C/C++源代码中,检查花括弧(是"("与
")","{"与"}")是否匹配,若不匹配,则输出不匹配花括弧所在的行与列。
2,巧排数字,将1,2,...,19,20这20个数字排成一排,使得相邻的两个数字之和为一个素数,且
首尾两数字之和也为一个素数。编程打印出所有的排法。
3,打印一个N*N的方阵,N为每边字符的个数( 3〈N〈20 ),要求最外层为"X",第二层为"Y",从第三层起每层依次打印数字0,1,2,3,...
例子:当N =5,打印出下面的图形:
X X X X X
X Y Y Y X
X Y 0 Y X
X Y Y Y X
X X X X X
普天C++笔试题
c++最后几个大题目是
1,实现双向链表删除一个节点P,在节点P后插入一个节点,这两个函数。
2,写一个函数将其中的\t都转换成4个空格。
3,windows程序的入口是哪里?写出windows消息机制的流程。
4,如何定义和实现一个类的成员函数为回调函数。
还有前面的几个:
1. class A{
int a;
int b;
}
问的是编译时的default constructor function的问题。
还有一个说,A有其他自己定义的构造函数,问是否还有default constructor function
还是什么来着,记不清乐。
2. c++里面是不是所有的动作都是main()引起的?如果不是,请举例。
3. c++里面如何声明const void f(void)函数为C库函数?(这个我前几天还看来着,
居然就忘记乐, )
对了,还考乐一些关于const的问题
问下列哪两个是等同的
int b;
A const int* a = &b;
B const* int a = &b;
C const int* const a = &b;
D int const* const a = &b;
还有一个是考类的成员函数是 void f() const;型的时候调用的问题。
幸好昨天刚刚看乐这部分的内容,呵呵
内联函数考了一题,问内联函数在编译时是否做参数类型检查。
虚函数也考了一题,不过不难。
class base{
public:
virtual void play(){
cout<<"base";
}
}
class son: public base{
public:
void play(){cout<<"son";}
}
void g(base & b){
b.play;
}
void main(){
son s;
g(s);
return;
}
我所收集的intel比试题&面试题:
(熟悉大公司的题目,并不仅仅是为了进这些公司,而是很多国内公司考察内容都很接近而已.)
2005笔试 :
1。高效的内存管理
2。8皇后问题
面试q:
(2) 编译中的问题:全局变量如int i=5; int*(pf)()=foo; 分别在何时被初始化?设计时候如何具体的实现。
(3) OS相关的问题,内存访问,cache等(包括cache在整个系统中的位置,画出来,并解释)
(4) 解释例如mov ax,100H 这样一条指令的cpu, os, memory等都完成了什么样的工作。
(5) Strlen()的C语言实现,不能使用任何变量。
(6) 编译中display表的一些问题
(7) 一个hash函数,输入随机,现发生冲突,如数据集中在某几条中,问怎样处理hash函数保证高效的访问,怎样实现?
(8) 把Switch()case…语句翻译成三元组。
(9) 一个byte(用C语言实现计数其中1的个数),给出最高效的实现方法。(位域)或者查表最快的;
(10) 上海有多少个加油站?你是怎样解决这一问题?
(11) C语言参数的入栈顺序?为什么这么实现?
(12) 你的最大的优点和缺点分别是什么?
(13) C语言中字符串的翻转,最高效率(时间和空间)的实现?
2004
1. 三个float:a,b,c 问值
(a+b)+c==(b+a)+c
(a+b)+c==(a+c)+b
2. 把一个链表反向填空
3. 设计一个重采样系统,说明如何anti-alias
4. y1(n)=x(2n), y2(n)=x(n/2),问:
如果y1为周期函数,那么x是否为周期函数
如果x为周期函数,那么y1是否为周期函数
如果y2为周期函数,那么x是否为周期函数
如果x为周期函数,那么y2是否为周期函数
5. 如果模拟信号的带宽为5KHZ,要用8K的采样率,怎么办。
4. 某个程序在一个嵌入式系统(200M的CPU,50M的SDRAM)中已经最化了,换到另一个系统
(300M的CPU,50M的SDRAM)中运行,还需要优化吗?
5. x^4+a*x^3+x^2+c*x+d最少需要作几次乘法
6. 什么情况下,sin(x+y)+y ~ ....
7. 下面哪种排序法对12354最快
a quick sort
b.buble sort
c.merge sort
8. 哪种结构,平均来讲,获取一个值最快
a. binary tree
b. hash table
c. stack
1。 pipeline
2。 程序流程图题目
3。 哲学家进餐
4。 32bit,64bit,两个平台上complier,linker,os kernel,library,debuger的性质
5。 const char * vs char const * (?)
6。 GDT and LDT
7。 1+1<<1
8。 Stack性质
9。 ???
10。正方体中压力什么的。。。
大题
1。f[40,400],log10变换
2。ACPI
3。读程序
4。频谱,采样分析
大题
1。写出下列信号的奈亏斯特频率
(1)f(t)=1+cos(2000pait)+sin(4000pait)
(2)f(t)=sin(4000pait)/pait
(3)f(t)=(sin(4000pait)的平方)/pait
2.填程序
把一个计算m^n的程序填充完整
大概的意思是:
有一个全局数组char s[BUFSIZE]
利用这个数组计算,就是每个单元存放计算结果的一位,index小的存放低位,index大
的存放高位
3。有两个线程
void producer()
{
while(1)
{
GeneratePacket();
PutPacketIntoBuffer();
Signal(customer);
}
}
void customer()
{
while(1)
{
WaitForSignal();
if(PacketInBuffer>10)
{
ReadAllPackets();
ProcessPackets();
}
}
}
(1)有没有其他方法可以提高程序的性能
(2)可不可以不使用信号之类的机制来实现上述的功能
4。优化下面的程序
(0)sum=0
(1)I=1
(2)T1=4*I
(3)T2=address(A)-4
(4)T3=T2[T1]
(5)T4=address(B)-4
(6)T5=4*I
(7)T6=T4[T5]
(8)T7=T3*T5
(9)sum=sum+T6
(10)I=I+1
(10)IF I<20 GOTO (2)
1。关于c的main函数
2。15个人循环报数,报到N的出列,找出最后留下的那个人,算法填空题
2。找出一个给出的并行解决方案的错误情况
3。关于GPIO,intel的四种体系结构
选择题10题
有关vc和c,指针,HyporThreading Dual-core等等
看也看不懂的
2003年的
1:概率题。x,y为随机变量,联合概率密度 f(x,y) = intig(0,1)*dx*intig(0,x)*k*d
y,k为常数,求k=? E(xy)=?
注:intig(a,b)为a到b的定积分。
2:概率题。A,B为随机事件,以下哪个正确
A. P(A U B)*p(AB) <= P(A)P(B)
B. P(A U B)*p(AB) >= P(A)P(B)
C. P(A U B)*p(AB) <= P(A) + P(B)
D. P(A U B)*p(AB) >= P(A) + P(B)
3: 信道带宽200kHz,信噪比10dB,求信道波特率=?
4:以下代码运行结果是什么
int main()
{
int a,b,c,abc = 0;
a=b=c=40;
if(c)
{
int abc;
abc = a*b+c;
}
printf("%d,%d", abc, c);
return 0;
}
5:给出了从纽约出发和到达落山鸡的各种航班信息,写出找到一条从纽约到落山鸡的最
短距离的航班组合的代码。
6:从计算机图形上截取某个物体边缘的若干个坐标,求这个物体面积,并跟判断是方形
还是圆形,为啥。(坐标不记得,大概是个圆
)。
7:离散卷机与DFT的区别与关系。快速求不满足2^N长度的离散傅立叶变换的方法有哪些
?如何用fft求N*M点的离散卷机?
8:给出fir和iir的优缺点。
9:如何计算线性标量量化器的量化噪声?需要那些假设?
请定义一个宏,比较两个数a、b的大小,不能使用大于、小于、if语句
2、如何输出源文件的标题和目前执行行的行数
3、两个数相乘,小数点后位数没有限制,请写一个高精度算法
4、写一个病毒
5、有A、B、C、D四个人,要在夜里过一座桥。他们通过这座桥分别需要耗时1、2、5、10分钟,只有一支手电,并且同时最多只能两个人一起过桥。请问,如何安排,能够在17分钟内这四个人都过桥?
2005年腾讯招聘
选择题(60)
c/c++ os linux 方面的基础知识 c的Sizeof函数有好几个!
程序填空(40)
1.(20) 4空x5
不使用额外空间,将 A,B两链表的元素交叉归并
2.(20) 4空x5
MFC 将树序列化 转存在数组或 链表中!
1.请定义一个宏,比较两个数a、b的大小,不能使用大于、小于、if语句
// 这样转向定义应该不算违规吧!^_^
#include "stdafx.h"
#include <string.h>
#include <iostream>
using namespace std;
#define Cmp(x,y) compare(x,y)
int compare( int a, int b)
{
a^=(1<<31); b^=(1<<31);
int i=31;
while ((i^-1) && !((a&(1<<i))^(b&(1<<i)))) i--;
return (i^-1)?(((a>>i)&1)?1:-1):0;
}
int _tmain()
{
int c;
c = Cmp(5,4);
cout<<c<<endl;
return 0;
}
jruv (~~~一叶落而知天下秋~~~) 的答案:
#define COMPARE(a,b) ((a)-(b)) //<0: a<b =0:a==b>0:a>b
2.如何输出源文件的标题和目前执行行的行数
cout << "Filename " << __FILE__ << " Line " << __LINE__ << endl;
3.两个数相乘,小数点后位数没有限制,请写一个高精度算法
算法提示:
输入 string a, string b; 计算string c=a*b; 返回 c;
1, 纪录小数点在a,b中的位置l1,l2, 则需要小数点后移动位置数为l=length(a)+length(b)-l1-l2-2;
2, 去掉a,b中的小数点,(a,b小数点后移,使a,b变为整数)
3, 计算c=a*b; (同整数的大数相乘算法)
4, 输出c,(注意在输出倒数第l个数时,输出一个小数点。若是输出的数少于l个,就补0)
du51(郁郁思扬)的答案:
变为整数求就行了.输入的时候记一下,小数点位置..输出再做点文章就行了.
下面的是大整数的运算.
#include<iostream>
using namespace std;
#define MAX 10000
struct Node{
int data;
Node *next;
};
void output(Node *head)
{
if(!head->next&&!head->data)return;
output(head->next);
cout<<head->data;
}
void Mul(char *a,char *b,int pos)
{
char *ap=a,*bp=b;
Node *head=0;
head=new Node;head->data=0,head->next=0; //头
Node *p,*q=head,*p1;
int temp=0,temp1,bbit;
while(*bp) //若乘数不为空 ,继续.
{
p=q->next;p1=q;
bbit=*bp-48; //把当前位转为整型
while(*ap||temp) //若被乘数不空,继续
{
if(!p) //若要操作的结点为空,申请之
{
p=new Node;
p->data=0;
p->next=0;
p1->next=p;
}
if(*ap==0)temp1=temp;
else { temp1=(p1->data)+(*ap-48)*bbit+temp;ap++; }
p1->data=temp1%10; //留当前位
temp=temp1/10; //进位以int的形式留下.
p1=p;p=p->next; //被乘数到下一位
}
ap=a;bp++;q=q->next; //q进下一位
}
p=head;
output(p); //显示
cout<<endl;
while(head) //释放空间
{
p=head->next;
delete head;
head=p;
}
}
int main()
{
cout<<"请输入两个数"<<endl;
char test1[MAX],test2[MAX];
cin.getline(test1,MAX,'\n');
cin.getline(test2,MAX,'\n');
Mul(strrev(test1),strrev(test2));
system("PAUSE");
return 0;
}
上面大整数已经写了.你加几个东西就行了.
#include<iostream>
using namespace std;
#define MAX 10000
struct Node{
int data;
Node *next;
};
void output(Node *head,int pos)
{
if(!head->next&&!head->data)return;
output(head->next,pos-1);
cout<<head->data;
if(!pos)cout<<".";
}
void Mul(char *a,char *b,int pos)
{
char *ap=a,*bp=b;
Node *head=0;
head=new Node;head->data=0,head->next=0; //头
Node *p,*q=head,*p1;
int temp=0,temp1,bbit;
while(*bp) //若乘数不为空 ,继续.
{
p=q->next;p1=q;
bbit=*bp-48; //把当前位转为整型
while(*ap||temp) //若被乘数不空,继续
{
if(!p) //若要操作的结点为空,申请之
{
p=new Node;
p->data=0;
p->next=0;
p1->next=p;
}
if(*ap==0)temp1=temp;
else { temp1=(p1->data)+(*ap-48)*bbit+temp;ap++; }
p1->data=temp1%10; //留当前位
temp=temp1/10; //进位以int的形式留下.
p1=p;p=p->next; //被乘数到下一位
}
ap=a;bp++;q=q->next; //q进下一位
}
p=head;
output(p,pos); //显示
cout<<endl;
while(head) //释放空间
{
p=head->next;
delete head;
head=p;
}
}
int main()
{
cout<<"请输入两个数"<<endl;
char test1[MAX],test2[MAX],*p;
int pos=0;
cin.getline(test1,MAX,'\n');
cin.getline(test2,MAX,'\n');
if(p=strchr(test1,'.'))
{
pos+=strlen(test1)-(p-test1)-1;
do
{
p++;
*(p-1)=*p;
}while(*p);
}
if(p=strchr(test2,'.'))
{
pos+=strlen(test2)-(p-test2)-1;
do
{
p++;
*(p-1)=*p;
}while(*p);
}
Mul(strrev(test1),strrev(test2),pos);
system("PAUSE");
return 0;
}
4.写一个病毒
cout<<"一个病毒"<<endl;
(开玩笑的,没搞过,^_^)
5.让你在100000000个浮点数中找出最大的10000个,要求时间复杂度优。
//本算法使用快排,O(n*lg(n))
//最低可以找到线性算法,使用预先区域统计划分!类试于构造Quad Trees! 写起来代码会长些!
#include <stdio.h>
#include <stdlib.h>
#define Max 100000000
int a[Max+10];
int cmp( const void *a, const void *b)
{
int *x = ( int *) a;
int *y = ( int *) b;
return *x-*y;
}
int main()
{
int n=0;
while (scanf("%d",&a[n])==1) n++;
qsort(a,n,4,cmp);
for ( int i=0;i<3;i++) printf("%d",a[ i ]);
return 1;
}
5 、有 A 、 B 、 C 、 D 四个人,要在夜里过一座桥。他们通过这座桥分别需要耗时 1 、 2 、 5 、 10 分钟,只有一支手电,并且同时最多只能两个人一起过桥。请问,如何安排,能够在 17 分钟内这四个人都过桥?
Solution:关键是时间最长的两个人必须同时过桥
The First Time : A(1) 和 B(2) 过桥, A(1) 返回 Cost : 1+2
The Second Time : C(5) 和 D(10) 过桥, B(2) 返回 Cost : 10+2
The Third Time A(1) 和 B(2) 过桥 Cost : 2
Total Time Cost : (1+2)+(10+2)+2=17 minutes
1.请定义一个宏,比较两个数a、b的大小,不能使用大于、小于、if语句
2.如何输出源文件的标题和目前执行行的行数
3.两个数相乘,小数点后位数没有限制,请写一个高精度算法
4.写一个病毒
微软
智力题
1.烧一根不均匀的绳子,从头烧到尾总共需要1个小时,问如何用烧绳子的方法来确定半小时的时间呢?
2.10个海盗抢到了100颗宝石,每一颗都一样大小且价值连城。他们决定这么分:
(1)抽签决定自己的号码(1~10);
(2)首先,由1号提出分配方案,然后大家表决,当且仅当超过半数的人同意时,按照他的方案进行分配,否则将被扔进大海喂鲨鱼;
(3)如果1号死后,再由2号提出分配方案,然后剩下的4个人进行表决,当且仅当超过半数的人同意时,按照他的方案进行分配,否则将被扔入大海喂鲨鱼;
(4)依此类推……
条件:每个海盗都是很聪明的人,都能很理智地做出判断,从而做出选择。
问题:第一个海盗提出怎样的分配方案才能使自己的收益最大化?
3.为什么下水道的盖子是圆的?
4.中国有多少辆汽车?
5.你让工人为你工作7天,回报是一根金条,这根金条平分成相连的7段,你必须在每天结束的时候给他们一段金条。如果只允许你两次把金条弄断,你如何给你的工人付费?
6.有一辆火车以每小时15公里的速度离开北京直奔广州,同时另一辆火车以每小时20公里的速度从广州开往北京。如果有一只鸟,以30公里每小时的速度和两辆火车同时启动,从北京出发,碰到另一辆车后就向相反的方向返回去飞,就这样依次在两辆火车之间来回地飞,直到两辆火车相遇。请问,这只鸟共飞行了多长的距离?
7.你有两个罐子以及50个红色弹球和50个蓝色弹球,随机选出一个罐子,随机选出一个弹球放入罐子,怎样给出红色弹球最大的选中机会?在你的计划里,得到红球的几率是多少?
8.想像你站在镜子前,请问,为什么镜子中的影像可以左右颠倒,却不能上下颠倒呢?
9.如果你有无穷多的水,一个3公升的提捅,一个5公升的提捅,两只提捅形状上下都不均匀,问你如何才能准确称出4公升的水?
10.你有一桶果冻,其中有黄色、绿色、红色三种,闭上眼睛抓取同种颜色的两个。抓取多少次就可以确定你肯定有两个同一颜色的果冻?
11.连续整数之和为1000的共有几组?
12.从同一地点出发的相同型号的飞机,可是每架飞机装满油只能绕地球飞半周,飞机之间可以加油,加完油的飞机必须回到起点。问至少要多少架次,才能满足有一架绕地球一周。
参考答案:
1.两边一起烧。
2.96,0,1,0,1,0,1,0,1,0。
3.因为口是圆的。
4.很多。
5.分1,2,4。
6.6/7北京到广州的距离。
7.100%。
8.平面镜成像原理(或者是“眼睛是左右长的”)。
9.3先装满,倒在5里,再把3装满,倒进5里。把5里的水倒掉,把3里剩下的水倒进5里,再把3装满,倒进5里,ok!
10.一次。
11.首先1000为一个解。连续数的平均值设为x,1000必须是x的整数倍。假如连续数的个数为偶数个,x就不是整数了。x的2倍只能是5,25,125才行。因为平均值为12.5,要连续80个达不到。125/262.5是可以的。即62,63,61,64,等等。连续数的个数为奇数时,平均值为整数。1000为平均值的奇数倍。10002×2×2×5×5×5;x可以为2,4,8,40,200排除后剩下40和200是可以的。所以答案为平均值为62.5,40,200,1000的4组整数。
12.答案是5架次。一般的解法可以分为如下两个部分:
(1)直线飞行
一架飞机载满油飞行距离为1,n架飞机最远能飞多远?在不是兜圈没有迎头接应的情况,这问题就是n架飞机能飞多远?存在的极值问题是不要重复飞行,比如两架飞机同时给一架飞机加油且同时飞回来即可认为是重复,或者换句话说,离出发点越远,在飞的飞机就越少,这个极值条件是显然的,因为n架飞机带的油是一定的,如重复,则浪费的油就越多。比如最后肯定是只有一架飞机全程飞行,注意“全程”这两个字,也就是不要重复的极值条件。如果是两架飞机的话,肯定是一架给另一架加满油,并使剩下的油刚好能回去,就说第二架飞机带的油耗在3倍于从出发到加油的路程上,有三架飞机第三架带的油耗在5倍于从出发到其加油的路程上,所以n架飞机最远能飞行的距离为s1+1/3+…+1/(2n+1)这个级数是发散的,所以理论上只要飞机足够多最终可以使一架飞机飞到无穷远,当然实际上不可能一架飞机在飞行1/(2n+1)时间内同时给n1个飞机加油。
(2)可以迎头接应加油
一架飞机载满油飞行距离为1/2,最少几架飞机能飞行距离1?也是根据不要重复飞行的极值条件,得出最远处肯定是只有一架飞机飞行,这样得出由1/2处对称两边1/4肯定是一架飞机飞行,用上面的公式即可知道一边至少需要两架飞机支持,(1/3+1/5)/2>1/4(左边除以2是一架飞机飞行距离为1/2),但是有一点点剩余,所以想像为一个滑轮(中间一个飞机是个绳子,两边两架飞机是个棒)的话,可以滑动一点距离,就说加油地点可以在一定距离内变动(很容易算出来每架飞机的加油地点和加油数量,等等)
数学篇
1.1000!有几位数,为什么?
2.F(n) 1 n>8 n<12
F(n) 2 n<2
F(n) 3 n 6
F(n)4 n other
使用+ * /和sign(n)函数组合出F(n)函数
sign(n) 0 n 0
sign(n)1 n<0
sign(n) 1 n>0
3.编一个程序求质数的和,例如F(7) 1+3+5+7+11+13 +17 57。
逻辑推理题
1.此题源于1981年柏林的德国逻辑思考学院,98%的测验者无法解答此题。
有五间房屋排成一列;所有房屋的外表颜色都不一样;所有的屋主来自不同的国家;所有的屋主都养不同的宠物;喝不同的饮料;抽不同的香烟。
(1)英国人住在红色房屋里;(2)瑞典人养了一只狗;(3)丹麦人喝茶;(4)绿色的房子在白色的房子的左边;(5)绿色房屋的屋主喝咖啡;(6)吸Pall Mall香烟的屋主养鸟;(7)黄色屋主吸Dunhill香烟;(8)位于最中间的屋主喝牛奶;(9)挪威人住在第一间房屋里;(10)吸Blend香烟的人住在养猫人家的隔壁;(11)养马的屋主在吸Dunhill香烟的人家的隔壁;(12)吸Blue Master香烟的屋主喝啤酒;(13)德国人吸Prince香烟;(14)挪威人住在蓝色房子隔壁;(15)只喝开水的人住在吸Blend香烟的人的隔壁
问:谁养鱼?
提示:首先确定
房子颜色:红、黄、绿、白、蓝 Color 1 2 3 4 5
国籍:英、瑞、丹、挪、德=> Nationality 1 2 3 4 5
饮料:茶、咖、奶、酒、水=> Drink 1 2 3 4 5
烟:PM、DH、BM、PR、混=> Tobacco 1 2 3 4 5
宠物:狗、鸟、马、猫、鱼=> Pet 1 2 3 4 5
然后有:
(9)=>N1=挪威
(14)=>C2=蓝
(4)=>如C3=绿,C4=白,则(8)和(5)矛盾,所以C4=绿,C5=白
剩下红黄只能为C1,C3
(1)=>C3=红,N3=英国,C1=黄
(8)=>D3=牛奶
(5)=>D4=咖啡
(7)=>T1=DH
(11)=>P2=马
那么:
挪威 ? 英国 ? ?
黄 蓝 红 绿 白
? ? 牛奶 咖啡 ?
DH ? ? ? ?
? 马 ? ? ?
(12)=>啤酒只能为D2或D5,BM只能为T2或T5=>D1=矿泉水
(3)=>茶只能为D2或D5,丹麦只能为N2或N5
(15)=>T2=混合烟=>BM=T5,
所以剩下啤酒=D5,茶=T2=>丹麦=D2
然后:
挪威 丹麦 英国 ? ?
黄 蓝 红 绿 白
矿泉水 茶 牛奶 咖啡 啤酒
DH 混合烟 ? ? BM
? 马 ? ? ?
(13)=>德国=N4,PR=T4
所以,瑞典=N5,PM=T3
(2)=>狗=P5
(6)=>鸟=P3
(10)=>猫=P1
得到:
挪威 丹麦 英国 德国 瑞典
黄 蓝 红 绿 白
矿泉水 茶 牛奶 咖啡 啤酒
DH 混合烟 PM PR BM
猫 马 鸟 ? 狗
所以,最后剩下的鱼只能由德国人养了。
2.
. . .
. . .
. . .
请仅用一笔画四根直线,将上图9个点全部连接。
3.对一批编号为1~100全部开关朝上(开)的灯进行以下操作:
凡是1的倍数反方向拨一次开关;2的倍数反方向又拨一次开关;3的倍数反方向又拨一次开关……
问:最后为关熄状态的灯的编号。
微软招聘总经理助理的三道面试题
1.某手机厂家由于设计失误,有可能造成电池寿命比原来设计的寿命短一半(不是冲放电时间),解决方案就是更换电池或给50元购买该厂家新手机的折换券。请给所有已购买的用户写信告诉解决方案。
2.一高层领导在参观某博物馆时,向博物馆馆员小王要了一块明代的城砖作为纪念,按国家规定,任何人不得将博物馆收藏品变为私有。博物馆馆长需要如何写信给这位领导,将城砖取回?
3.王小姐由于工作失误,将2万元的笔记本电脑以1.2万元错卖给李先生,王小姐的经理应该怎么写信给李先生将钱要回?
英文面试题目
1. Algorithms
* What’s the difference between a linked list and an array?
* Implement an algorithm to sort a linked list. Why did you pick the method you did?
* Implement an algorithm to sort an array. Why did you pick the method you did?
* Implement strstr() (or some other string library function).
* Reverse a string. Optimize for speed. Optimize for space.
* Count the number of set bits in a number. Now optimize for speed. Now optimize for size.
* How would you find a cycle in a linked list?
* Give me an algorithm to shuffle a deck of cards, given that the cards are stored in an array of ints.
* Write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value.
* Write a function to print all of the permutations of a string.
* Implement malloc.
* Write a function to print the Fibonacci numbers.
* Write a function to copy two strings, A and B. The last few bytes of string A overlap the first few bytes of string B.
* How would you print out the data in a binary tree, level by level, starting at the top?
2. Applications
* How can computer technology be integrated in an elevator system for a hundred story office building? How do you optimize for availability? How would variation of traffic over a typical work week or floor or time of day affect this?
* How would you redesign an ATM?
* Suppose we wanted to run a microwave oven from the computer. What kind of software would you write to do this?
* How would you design a coffee-machine for an automobile.
3. Thinkers
* How are M&Ms made?
* If you had to learn a new computer language, how would you go about doing it?
* If MS told you we were willing to invest $5 million in a start up of your choice, what business would you start? Why?
* If you could gather all of the computer manufacturers in the world together into one room and then tell them one thing that they would be compelled to do,what would it be?
* Explain a scenario for testing a salt shaker.
* If you are going to receive an award in 5 years, what is it for and who is the audience?
* How would you explain how to use Microsoft Excel to your grandma?
* Why is it that when you turn on the hot water in any hotel, for example, the hot water comes pouring out almost instantaneously?
微软亚洲技术支持中心面试题目
1.进程和线程的差别。
2.Heap与stack的差别。
3.Windows下的内存是如何管理的?
4.介绍.Net和.Net的安全性。
5.客户端如何访问.Net组件实现Web Service?
6.C/C++编译器中虚表是如何完成的?
7.谈谈COM的线程模型。然后讨论进程内/外组件的差别。
8.谈谈IA32下的分页机制。
9.给两个变量,如何找出一个带环单链表中是什么地方出现环的?
10.在IA32中一共有多少种办法从用户态跳到内核态?
11.如果只想让程序有一个实例运行,不能运行两个。像winamp一样,只能开一个窗口,怎样实现?
12.如何截取键盘的响应,让所有的‘a’变成‘b’?
13.Apartment在COM中有什么用?为什么要引入?
14.存储过程是什么?有什么用?有什么优点?
15.Template有什么特点?什么时候用?
16.谈谈Windows DNA结构的特点和优点。
微软研究院笔试题目
1.#include <stdio.h>
#include <String.h>
class CBuffer
{
char * m_pBuffer;
int m_size;
publc:
CBuffer()
{
m_pBuffer=NULL;
}
~CBuffer()
{
Free();
}
void Allocte(int size)
{
m_size=size;
m_pBuffer= new char[size];
}
private:
void Free()
{
if(m_pBuffer!=NULL)
{
delete m_pBuffer;
m_pBuffer=NULL;
}
}
public:
void SaveString(const char* pText) const
{
strcpy(m_pBuffer, pText);
char* GetBuffer() const
{
return m_pBuffer;
}
};
void main (int argc, char* argv[])
{
cBuffer buffer1;
buffer1.SaveString(“Microsoft”);
printf(buffer1.GetBuffer());
}
}
找出Allocate, SaveString, main的错误。
2.打印“Welcome MSR Asia”
#include <stdio.h>
#include <string.h>
char * GetName (void)
{
//To return “MSR Asia” String
char name[]=“MSR Asia”;
return name;
}
void main(int argc, char* argv[])
{
char name[32];
//Fill in zeros into name
for(int i=0;i<=32;i++)
{
name[1]=‘\0‘;
}
//copy “Welcome” to name
name=“Welcome”;
//Append a blank char
name[8]=”;
//Append string to name
strcat(name,GetName());
//print out
printf(name);
}
找出程序中的错误。
3.#include <stdio.h>
class A
{
public:
void FuncA()
{
printf(“FuncA called\n”);
}
virtual void FuncB()
{
printf(“FuncB called\n”);
}
};
class B: public A
{
public:
void FuncA()
{
A::FuncA();
printf(“FuncAB called\n”);
}
virtual void FuncB()
{
printf(“FuncBB called\n”);
}
};
void main(void)
{
B b;
A *pa;
pa=&b;
A *pa2=new A;
b.FuncA();
b.FuncB();
pa->FuncA();
pa->FuncB();
pa2->FuncA();
pa2->FuncB();
delete pa2;
}
What is the output of the above program?
4.#include <stdio.h>
#include <string.h>
int FindSubString(char* pch)
{
int count=0;
char* p1=pch;
while(*p1!=‘\0’)
{
if(*p1==p1[1]-1)
{
p1++;
count++;
}
else
{
break;
}
}
int count2=count;
while(*p1!=‘\0’)
{
if(*p1!==p1[1]+1)
{
p1++;
count2--;
}
else
{
break;
}
if(count2==0)
return count;
return 0;
}
void ModifyString(char* pText)
{
char* p1=pText;
char* p2=p1;
while(*p1!=‘\0’)
{
int count=FindSubString(p1);
if(count>0)
{
*p2++=*p1;
sprintf(p2, “%I”, count);
while(*p2!= ‘\0’)
{
p2++;
}
p1+=count+count+1;
}
else
{
*p2++=*p1++;
}
}
}
void main(void)
{
char text[32]=“XYBCDCBABABA”;
ModifyString(text);
printf(text);
}
In the main() function, after ModifyString(text) is called, what’s the value of ‘text’?
微创笔试题目(微创,微软在中国的合资公司)
1.上海的苏州河由于遭受多年的工业污染,一直是条臭水沟。上海市政府下了很大决心清理苏州河,你觉得需要几年能让河水变清?你的依据是什么?
2.找出字符串A中包含的字符可以进行的所有不同组合。例如:abccd中,ab,ac,bc,cc,abd等都是可能的组合。(请用C/C++编程,不允许上机操作)
3.请估算月球的体积。
4.经常去的技术网站,请举例。
5.对软件开发过程的理解。
6.上海有多少外籍和港澳台人士?你的依据是什么?(不得引用政府和调研机构数据)
7.字符串A是由n个小写英文字母(a ~ z)构成的,定义为char A[n]。你能用更少的空间表示这个字符串吗?请写出从char A[n]到你的新的储存格式的转换函数。(请用C/C++编程,不允许上机操作)
8.哈希表和数组的定义,区别,优缺点。
9.用递归实现菲波列数列。
10.用dhtml写页面。
11.一楼到十楼的每层电梯门口都放着一颗钻石,钻石大小不一。你乘坐电梯从一楼到十楼,每层楼电梯门都会打开一次,只能拿一次钻石,问怎样才能拿到最大的一颗? (去年应聘到微创的S小姐面试遇到的就是这道智力题。她的回答是:选择前五层楼都不拿,观察各层钻石的大小,做到心中有数。后五层楼再选择,选择大小接近前五层楼出现过最大钻石大小的钻石。她至今也不知道这道题的准确答案,“也许就没有准确答案,就是考一下你的思路,”她如是说。)
12.U2合唱团在17分钟内得赶到演唱会场,途中必需跨过一座桥,四个人从桥的同一端出发,你得帮助他们到达另一端,天色很暗,而他们只有一只手电筒。一次同时最多可以有两人一起过桥,而过桥的时候必须持有手电筒,所以就得有人把手电筒带来带去,来回桥两端。手电筒是不能用丢的方式来传递的。四个人的步行速度各不同,若两人同行则以较慢者的速度为准。Bono需花1分钟过桥,Edge需花2分钟过桥,Adam需花5分钟过桥,Larry需花10分钟过桥。他们要如何在17分钟内过桥呢?(有个同济的学生写文章说他当时在微软面试时就是碰到了这道题,最短只能做出在19分钟内过桥,微软的人对他讲这样的结果已经是不错的了!)
13.烧一根不均匀的绳要用一个小时,如何用它来判断半个小时?(参考答案:两边一起烧)
14.为什么下水道的盖子是圆的?(从复旦大学一位计算机系教授那里听来的答案:因为如果是方的、长方的或椭圆的,那无聊之徒拎起来它就可以直接扔进地下道啦!但圆形的盖子嘛,就可以避免这种情况了)
15.有7克、2克砝码各一个,天平一只,如何只用这些物品三次将140克的盐分成50、90克各一份?
Intel笔试面试题目
智力题
1.每天中午从法国塞纳河畔的勒阿佛有一艘轮船驶往美国纽约,在同一时刻纽约也有一艘轮船驶往勒阿佛。已知横渡一次的时间是7天7夜,轮船匀速航行,在同一航线,轮船近距离可见。
请问今天中午从勒阿佛开出的船会遇到几艘从纽约来的船?
2.巴拿赫病故于1945年8月31日。他的出生年份恰好是他在世时某年年龄的平方,问:他是哪年出生的?
答案:
设他在世时某年年龄为x,则x的平方<1945,且x为自然数。其出生年份x的平方xx(x1),他在世年龄1945x(x1)。1945的平方根44.1,则x应为44或略小于此的数。而x44时,x(x1)44×431892,算得其在世年龄为1945189253;又x43时,x(x1)43×421806,得其在世年龄为19451806139;若x再取小,其在世年龄越大,显然不妥。故x44,即他出生于1892年,终年53岁。
3.
(图形描述:一个各边相等的十字图案)
上图中各边相等,要求:用最少的分割,拼成一个正方形。
笔试题目
1.设计一个重采样系统,说明如何anti-alias。
2.y1(n)x(2n),y2(n)x(n/2),问:
如果y1为周期函数,那么x是否为周期函数?
如果x为周期函数,那么y1是否为周期函数?
如果y2为周期函数,那么x是否为周期函数?
如果x为周期函数,那么y2是否为周期函数?
3.如果模拟信号的带宽为5kHz,要用8k的采样率,怎么办。
4.某个程序在一个嵌入式系统(200M的CPU,50M的SDRAM)中已经最优化了,换到另一个系统(300M的CPU,50M的SDRAM)中运行,还需要优化吗?
5.x^4+a*x^3+x^2+c*x+d最少需要做几次乘法。
6.三个float:a,b,c
问值:
(a+b)+c(b+a)+c
(a+b)+c(a+c)+b
7.把一个链表反向填空。
8.下面哪种排序法对12354最快? 。
A. quick sort
B. buble sort
C. merge sort
9.哪种结构平均来讲获取一个值最快? 。
A. binary tree
B. hash table
C. stack
10.
#include “stdafx.h”
#include <iostream.h>
struct bit
{ int a:3;
int b:2;
int c:3;
};
int main(int argc, char* argv[])
{ bit s;
char *c = (char*)&s;
*c = 0x99;
cout << s.a <<endl <<s.b<<endl<<s.c<<endl;
return 0;
}
Output:?
11.
挑bug,在linux下运行:
#include <stdio.h>
char *reverse(char* str)
{
int len=0, i=0;
char *pstr=str, *ptemp,*pd;
while(*++pstr)
len++;
pstr--;
//ptemp=(char*)malloc(len+1);
ptemp=(char*)malloc(len+1);
pd=ptemp;
while(len--){
*ptemp=*pstr;
ptemp++;
pstr--;
i++;
}
*ptemp=*pstr;
ptemp++;
*ptemp=‘\0’;
return pd;
}
main()
{
char string[40]= “Hello World!”;
char *pstr=string;
printf(“%s”, pstr);
printf(“%s”, reverse(pstr));
}
实验室笔试题
1.写出下列信号的奈亏斯特频率
(1)f(t)1cos(2000pait)sin(4000pait)
(2)f(t)sin(4000pait)/pait
(3)f(t)(sin(4000pait)的平方)/pait
2.有两个线程
void producer()
{
while(1)
{
GeneratePacket();
PutPacketIntoBuffer();
Signal(customer);
}
}
void customer()
{
while(1)
{
WaitForSignal();
if(PacketInBuffer>10)
{
ReadAllPackets();
ProcessPackets();
}
}
}
(1)有没有其他方法可以提高程序的性能
(2)可不可以不使用信号之类的机制来实现上述的功能
3.优化下面的程序
(0)sum0
(1)I1
(2)T14*I
(3)T2address(A)4
(4)T3T2[T1]
(5)T4address(B)4
(6)T54*I
(7)T6T4[T5]
(8)T7T3*T5
(9)sumsum+T6
(10)II+1
(11)IF I<20 GOTO (2)
面试题目
1.下面这段代码不符合Pipeline要求,请你改动一下
if(a>b)
i0;
else
i1;
2.对于运行在ring3上的这个指令,请你指出CPU和操作系统分别参与了哪部分操作?
mov eax, [0x12345678]
3.如果有一个芯片,只是裸机,如何写它的操作系统?最难的部分在哪儿?如何解决?
4.如何写一个主板的BIOS?
5.没有操作系统来给你完成它的一些初始化工作,如何写出PCI的driver?
Intel 2004北京笔试题
问答题
1.你觉得C程序中为什么会有main(),有没有想过exit,return,或什么都不做也可以让程序正常终止?
2.TOTAL个人围一圈,从1开始数到N,谁数到N出圈,下一个人继续从1开始数,返回最后一个出局的人。
#define TOTAL 15;
int xxxx(int N)
{
int ring[TOTAL] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1} //全是1
int nextstart = 0, counter=0;
for (i =1; i<TOTAL; i++){
counter = 0;
while(counter <N) {
if (_______________)
( ;)
else
(____________;)
}
ring[nextstart]=0
}
return nextstart +1;
}
3.列举Intel四种架构
4.概率题
(1)x, y为随机变量,联合概率密度f(x,y) intig(0,1)* dx*intig(0,x)*k*dy,k为常数,求k? E(xy) ?
注:intig(a,b)为a到b的定积分。
(2)A,B为随机事件,以下哪个正确 。
A.P(A U B)*p(AB) < P(A)P(B)
B.P(A U B)*p(AB) > P(A)P(B)
C.P(A U B)*p(AB) < P(A) + P(B)
D.P(A U B)*p(AB) > P(A) + P(B)
5.信道带宽200kHz,信噪比10dB,求信道波特率?
6.以下代码运行结果是 。
int main()
{
int a,b,c,abc = 0;
a=b=c=40;
if(c)
{
int abc;
abc = a*b+c;
}
printf(“%d,%d”, abc, c);
return 0;
}
7.给出了从纽约出发和到达洛杉机的各种航班信息,写出找到一条从纽约到洛杉机的最短距离的航班组合的代码。
8.从计算机图形上截取某个物体边缘的若干个坐标,求这个物体的面积,并判断是方形还是圆形,说明原因。
9.离散卷机与DFT的区别与关系。快速求出不满足2^N长度的离散傅立叶变换的方法有哪些?如何用fft求N*M点的离散卷机?
10.给出fir和iir的优缺点。
11.如何计算线性标量量化器的量化噪声?需要哪些假设?
IBM
IBM笔试题目
字母矩阵题目(15分钟)
给你一个矩阵:
(一) (二) (三) (四) (五)
1 a b c d e
2 b c a e d
3 c b e a d
4 c e d b a
5 e d a c b
回答以下问题。
(1)将第一行和第四行交换后,第一行第四个字母下面的左边的下面的右边的字母是 。
①a ②b ③c ④d ⑤e
(2)将所有出现在d左边的字母从矩阵中删掉。将所有出现在a左边的c字母从矩阵中删掉。如果矩阵中剩下的字母的种类的数目大于3,答案为原矩阵中左上方至右下方对角线上出现两次的字母。如果矩阵中剩下的字母的种类的数目小于或者等于3,答案为原矩阵中右上至左下对角线上出现4次的字母是 。
①a ②b ③c ④d ⑤e
(3)将所有的a用4替换,所有的d用2替换,哪一列的总和 最大
①第1列 ②第2列 ③第3列 ④第4列 ⑤第五列
(4)从左上角的字母开始,顺时针沿矩阵外围,第4次出现的字母是 。
①a ②b ③c ④d ⑤e
(5)沿第5列从上到下,接着沿第3列从下到上,接着沿第4列从上到下,接着沿第1列从下到上,接着沿第2列从上到下,第1个出现5次的字母是 。
①a ②b ③c ④d ⑤e
(6)从左上角的字母开始,顺时针沿矩阵外围,第4次出现的字母是以下哪个 。
①a ②b ③c ④d ⑤e
智力题
1.有50家人家,每家一条狗。有一天警察通知,50条狗当中有病狗,行为和正常狗不一样。每人只能通过观察别人家的狗来判断自己家的狗是否生病,而不能看自己家的狗,如果判断出自己家的狗病了,就必须当天一枪打死自己家的狗。结果,第一天没有枪声,第二天没有枪声,第三天开始一阵枪响,问:一共死了几条狗?
2.已知两个数字为1~30之间的数字,甲知道两数之和,乙知道两数之积,甲问乙:“你知道是哪两个数吗?”乙说:“不知道”。乙问甲:“你知道是哪两个数吗?”甲说:“也不知道”。于是,乙说:“那我知道了”,随后甲也说:“那我也知道了”,这两个数是什么?
3.一个经理有三个女儿,三个女儿的年龄加起来等于13,三个女儿的年龄乘起来等于经理自己的年龄。有一个下属已知道经理的年龄,但仍不能确定经理的三个女儿的年龄,这时经理说只有一个女儿的头发是黑的,然后这个下属就知道了经理的三个女儿的年龄。请问三个女儿的年龄分别是多少?为什么?
答案:
1.死了3条(第几天枪响就有几条)。
简单分析:从有一条不正常的狗开始,显然第一天将会听到一声枪响。这里的要点是你只需站在那条不正常狗的主人的角度考虑。
有两条的话思路继续,只考虑有两条不正常狗的人,其余人无需考虑。通过第一天他们了解了对方的信息。第二天杀死自己的狗。换句话说每个人需要一天的时间证明自己的狗是正常的。有三条的话,同样只考虑那三个人,其中每一个人需要两天的时间证明自己的狗是正常的狗。
2.1和4,或者4和7。
3.分别是2,2,9。
简单分析:
1 1 11 11 伪穷举,呵呵
1 2 10 20
1 3 9 27
1 4 8 32
1 5 7 35
1 6 6 36 在所有的可能性中,只有这两个相同,如果经理的年龄为其他,则他下属就可以确定三个人分别为几岁了
2 2 9 36 所以只有两种可能:1,6,6或者2,2,9。如果是1,6,6的话,那么两个同样大的6岁的孩子应该都是黑头发
2 3 8 40 所以只有2,2,9比较合理,大的那个是黑头发,另外两个是黄毛丫头
2 4 7 56
2 5 6 60
3 3 7 42
3 4 6 72
3 5 5 75
4 4 5 80
社会招聘笔试题
1.一个粗细均匀的长直管子,两端开口,里面有4个白球和4个黑球,球的直径、两端开口的直径等于管子的内径,现在白球和黑球的排列是wwwwbbbb,要求不取出任何一个球,使得排列变为bbwwwwbb。
2.一只蜗牛从井底爬到井口,每天白天蜗牛要睡觉,晚上才出来活动,一个晚上蜗牛可以向上爬3尺,但是白天睡觉的时候会往下滑2尺,井深10尺,问蜗牛几天可以爬出来?
3.在一个平面上画1999条直线最多能将这一平面划分成多少个部分?
4.在太平洋的一个小岛上生活着土人,他们不愿意被外人打扰,一天,一个探险家到了岛上,被土人抓住,土人的祭司告诉他,你临死前还可以有一个机会留下一句话,如果这句话是真的,你将被烧死,是假的,你将被五马分尸,可怜的探险家如何才能活下来?
5.怎样种四棵树使得任意两棵树的距离相等。
6.27个小运动员在参加完比赛后,口渴难耐,去小店买饮料,饮料店搞促销,凭三个空瓶可以再换一瓶,他们最少买多少瓶饮料才能保证一人一瓶?
7.有一座山,山上有座庙,只有一条路可以从山上的庙到山脚,每周一早上8点,有一个聪明的小和尚去山下化缘,周二早上8点从山脚回山上的庙里,小和尚的上下山的速度是任意的,在每个往返中,他总是能在周一和周二的同一钟点到达山路上的同一点。例如,有一次他发现星期一的8点30和星期二的8点30他都到了山路靠山脚的3/4的地方,问这是为什么?
8.有两根不均匀分布的香,每根香烧完的时间是一个小时,你能用什么方法来确定一段15分钟的时间?
英文面试题目
1. Describe your greatest achievement in the past 4-5 years?
2. What are your short & long term career objectives? What do you think is the most ideal job for you?
3. Why do you want to join IBM? What do you think you can contribute to IBM?
宝洁公司(P&G)面试题目
宝洁公司招聘题号称由高级人力资源专家设计,无论您如实或编造回答,都能反应您某一方面的能力。核心部分的题目如下:
Please provide concise examples that will help us better understand your capabilities.
1. Describe an instance where you set your sights on a high/demanding goal and saw it through completion.
2. Summarize a situation where you took the initiative to get others going on an important task or issue, and played a leading role to achieve the results you wanted.
3. Describe a situation where you had to seek out relevant information, define key issues, and decide on which steps to take to get the desired results.
4. Describe an instance where you made effective use of facts to secure the agreement of others.
5. Give an examples of how you worked effectively with people to accomplish an important result.
6. Describe a creative/innovative idea that you produced which led to a significant contribution to the success of an activity or project.
7. Provide an example of how you assessed a situation and achieved good results by focusing on the most important priorities.
8. Provide and example of how you acquired technical skills and converted them to practical application
解答范例:
1. Demnding Goal: To design a musical and dramatic show to celebrate the centennial Anniversary of Tianjin University.
The person who reach this goal: Chairman of Tianjin University Student Union What I learned from this observation: It is not necessary for a true leader to be an expert in such or such field of his career. But he must possessthe charismatic and the capacity to drive different people, who have diverging opinions, or even conflicting interests, to proceed togother to the sameorganizational goal.
2. The activity I initiated: To organize a group to sing English anthems on Charistmas Eve, visit all domitories in university and send christmas gifts on behalf of our English Association The desired result: To broaden the students’ horizons about Western culture.
My leading role: Combine the representatitives’ suggestions with my idea and draw the decision on:
* What songs to play?
* Who could attend the choir?
* Which spots we performed on?
The result: Many students said that they felt the warmness we sent to them and they hoped we would hold such activities next Charistmas.
3. Background: I organized the first activity after the establishment of the Management School English Association.
The desired result: To help the freshmen and the sophomores with their English while publicizing our group.
Key issue:
* What aspect of the students’ English abilities needed refining? Relevant Information:
* What kind of entertainment was popular among students and also offered chances for them to learn English most effectively?
* Which foreign teacher was suitable for this position?
* When was our member free?
* Whch place was convenient for most attendances?
* Other related factors, such as the availibility of facilities and the layout of the spots.
4. Background: I advanced a plan to found an English Garden in collaboration with fraternal association in neighboring university.
The disagreement:
* The authority of our school may dissent.
* The cost was expensive, and we had no enough human resoure to carry on this project.
* There were too many English corners. Another one was unneccessaty. The facts I made use:
* Our dean approved this proposal.
* Our partner was willing to provide financial assistantship. And our members volunteered to design the details of the plan and implement it.
* The poll showed that the current English corners did not meet the students’ requirement and lacked uniqueness. The result: Others were convinced and we founded the English Garden successfully.
5. Background: In the military training, we hold a Military Songs Competition.
Working procedure:
Design: I cooperated with my collegues to figure out the climax of the performance, the musical accompaniment of the songs and the whole arrnagement ofthe narrative poem.
Rehearsal: I worked together with those who were in charge of the lights, sounds and scenes to create the perfect artistic effect.
On stage: I reminded my fellows with gestures and eye expressions. Also, we coped with an emergency coherently.
The result: Our military team won the second prize in this competition.
6. Activity: To hold the Perspective Entrepreneur Contest.
The innovative idea I produced: To simulat a board meeting of a company, in which our candidates debated the feasibility of selling modern fitness equipment according to the market information they collected.
The result: The contest was hold based on my proposal.
7. Background: On one morning when our promotion month first began, I found that the inventories in some department stores were not adequate.
My assessment of the situation: The four promoting stores were not very far from each other, and the time they opened was not the same. It was possible to fetch some stock from another store and made up for it later.
The priorities: To satisfy the stocking demand of the store which had the largest number of customers.
8. Background: In the inverstigation of customers’ opinions about the taste of a new kind of beer, I found that the questionnaire form was out of date and limited the freedom of the responsers’ choices.
Technical skills: The scientific arrangement of questionnaire form
The result: With the help the converted form, our company obtained more objective and effective information.
飞利浦笔试试题
1.用逻辑门和cmos电路实现ab+cd。
2.用一个二选一mux和一个inv实现异或。
3.给了reg的setup和hold时间,求中间组合逻辑的delay范围。
4.如何解决亚稳态。
5.用Verilog/VHDL写一个fifo控制器。
6.用Verilog/VDDL检测stream中的特定字符串。
阿尔卡特(中国)的面试题目
全部用C语言完成:
1.自己定义数据结构,写出程序:在一个单向链表中,往I位置插入一个节点。
2.自己定义数据结构,写出程序:二叉树的前序遍历。
3.不允许使用系统时间,写出一个随机数生成函数。
Google
这次是连环游戏,每一题的答案将在下一题中用到。
1、{first 10-digit prime found in consecutive digits e}.com.
e中出现的连续的第一个10个数字组成的质数。
2、7427466391.com
Congratulations,Youve made it to level 2. Go to www.Linux.org and enter Bobsyouruncle as the login and the answer to this equation as the password.
f(1)=7182818284
f(2)=8182845904
f(3)=8747135266
f(4)=7427466391
f(5)=__________
update:提示:f(1)到f(4)是e中连续的10个数字满足总和等于49的前4个,f(5)当然是让你搜索第5个咯,编个小程序吧。
答案:5966290435
3、www.Linux.org
4、www.google.com/labjobs/
via:
Google recruits eggheads with mystery billboard
Mysterious Billboard May Be Google Recruitment Ad
Myserious billboard
Google is behind mystery geek trap
写一句俳句来描述搜索流量季节性预测的可能方法。
用三种颜色为一个二十面体涂颜色,每面都要覆盖,你能够用多少种不同的涂法?你将选择哪三种颜色?
这是一个我们故意留给你你空白,请填充一些你喜欢的东西。
戴尔
I.Choose one question and write down the trouble shooting steps in English ( 4-5 steps )
1.Customer report his computer cannot start after sudden power lost. How will you trouble shoot and find out the cause of the failure.
2.One computer was used normally last day, but today, the user cannot connect to internet via dial-up networking.
3.Customer complain the system send out great noise. What’s the detail action to identify the faulty part?
4.My computer was suddenly disconnected from LAN, how to trouble shoot?
5.My computer was hung up. After reboot, only one cursor blinked on the upper-left corner. How to fix this problem.
II. Reading and translation:
Passage 1.
Customer called in and reported the battery weren’t charging, System LED indicator was in yellow.
1.Suggested customer remove the battery from the battery bay by sliding the latch at the bottom of Notebook. Checked the battery power level by pressing the check button on the battery. It indicated no power.
2.Suggested customer remove the CD ROM off the Media bay, then plug the Battery to the media bay, it was still same result.
3.Suggested customer try with other battery, in the battery bay and media bay, it was ok. Battery could be charged.
4.Requested customer provide the DSN number from the fail battery. CN-05H980-69502-21U-01GB.
Informed customer that we would send a replaced battery to her.
Passage 2.
Customer bought a Notebook 20 day ago, then discovered that when she adjusted the Brightness of the LCD, the LCD would turn to very dim. She must reboot the Notebook few times before the LCD might display normally.
1.Suggested her try gently apply pressure above the keyboard near the LEDS and power button.
2.Suggested her swivel the LCD back and forth and lightly tap the plastic back of LCD.
3.Suggested her gently apply pressure on the bezel surrounding the screen. the problem persisted, after these testing.
4.Requested customer to update BIOS and alter the LCD Brightness control setting in the BIOS. After checking BIOS the problem persisted.
I told customer we would have engineer onsite replace the LCD Panel.
Computer communications
Different kinds of computers use different methods, or protocols, to communicate with each other. Macintosh computers use the AppleTalk protocol. Macintosh as well as PCs can use TCP/IP to share information on the Internet. Some PCs require a Network Operating System (NOS) to communicate. For example, Novell Netware is a popular NOS with PC users.
意法半导体软件试题
A Test for The C Programming Language
I. History
1. C was originally designed for and implemented on the (what) operating system on the DEC PDP-11, by (who) .
2. The most recently approved ANSI/ISO C standard was issued in (when) , and single line comments notation “//” is or isn’t a feature of C89.
II. Syntax and Semantics
1. In a runtime C program, auto variables are stored in , static variables are stored in , and function parameters are stored in .
a. stack b. heap c. neither stack nor heap
2. The statement “extern int x;” is a , and the keyword extern is used during .
a. variable declaration b. variable definition
c. compilation time d. runtime
3. There is a complicated declaration: void ( * signal (int, void (*)(int)) ) (int);
If a statement “typedef void (*p) (int);” is given, please rewrite this complicated declaration.
4. The following code is a segment of C program.
..........
void func(int *p)
{...........}
..........
main()
{
int num=0;
.........
func(&num);
........
}
..........
Here, the function argument “&num” is passed .
a. by value b. by reference
III. Practice
Create a tree, which has h (h>0) layers, and its each node has w (w>0) sub-nodes.
Please complete the following incomplete solution.
#include <stdlib.h>
#include <string.h>
struct tree{
char info;
p_sub; //link to sub-nodes
};
// allocate memory and initiate
void dnode ( struct tree* tmp )
{
= malloc( sizeof (struct tree) );
= 0x41;
= NULL;
}
struct tree *dtree (struct tree* subtree, int height, int width)
{
int i;
if ( !subtree ) //if necessary, allocte memory for subtree
denode(subtree);
if ( height == 1 )
return subtree;
else if ( height == 2 ) {
struct tree *leaf = NULL;
for ( i=0; i<width; i++ ) {
denode ( );
;
leaf = NULL;
}
return subtree;
}
else {
for ( i=0; i<width; i++ ) {
}
return subtree;
}
}
main()
{
.........
struct tree *root = NULL;
root = dtree (root, h, w) ; // h and w are integers get from input
.........
}
Sony笔试题
1.完成下列程序
*
*.*.
*..*..*..
*...*...*...*...
*....*....*....*....*....
*.....*.....*.....*.....*.....*.....
*......*......*......*......*......*......*......
*.......*.......*.......*.......*.......*.......*.......*.......
#include <stdio.h>
#define N 8
int main()
{
int i;
int j;
int k;
---------------------------------------------------------
| |
| |
| |
---------------------------------------------------------
return 0;
}
2.完成程序,实现对数组的降序排序
#include <stdio.h>
void sort( );
int main()
{
int array[]={45,56,76,234,1,34,23,2,3}; //数字任//意给出
sort( );
return 0;
}
void sort( )
{
____________________________________
| |
| |
|-----------------------------------------------------|
}
3.费波那其数列,1,1,2,3,5……编写程序求第十项。可以用递归,也可以用其他方法,但要说明你选择的理由。
#include <stdio.h>
int Pheponatch(int);
int main()
{
printf("The 10th is %d",Pheponatch(10));
return 0;
}
int Pheponatch(int N)
{
--------------------------------
| |
| |
--------------------------------
}
4.下列程序运行时会崩溃,请找出错误并改正,并且说明原因。
#include <stdio.h>
#include <malloc.h>
typedef struct{
TNode* left;
TNode* right;
int value;
} TNode;
TNode* root=NULL;
void append(int N);
int main()
{
append(63);
append(45);
append(32);
append(77);
append(96);
append(21);
append(17); // Again, 数字任意给出
}
void append(int N)
{
TNode* NewNode=(TNode *)malloc(sizeof(TNode));
NewNode->value=N;
if(root==NULL)
{
root=NewNode;
return;
}
else
{
TNode* temp;
temp=root;
while((N>=temp.value && temp.left!=NULL) || (N<temp. value && temp. right!=NULL
))
{
while(N>=temp.value && temp.left!=NULL)
temp=temp.left;
while(N<temp.value && temp.right!=NULL)
temp=temp.right;
}
if(N>=temp.value)
temp.left=NewNode;
else
temp.right=NewNode;
return;
}
}
华为笔试题
1.请你分别画出OSI的七层网络结构图和TCP/IP的五层结构图。
2.请你详细地解释一下IP协议的定义,在哪个层上面?主要有什么作用?TCP与UDP呢?
3.请问交换机和路由器各自的实现原理是什么?分别在哪个层次上面实现的?
4.请问C++的类和C里面的struct有什么区别?
5.请讲一讲析构函数和虚函数的用法和作用。
答:析构函数是在对象生存期结束时自动调用的函数,用来释放在构造函数分配的内存。
虚函数是指被关键字virtual说明的函数,作用是使用C++语言的多态特性
6.全局变量和局部变量有什么区别?是怎么实现的?操作系统和编译器是怎么知道的?
答:一些变量在整个程序中都是可见的,它们称为全局变量。一些变量只能在一个函数中可知,称为局部变量。这就是他们的区别。在任何函数外面定义的变量就是全局变量,在函数内部定义的变量是局部变量,这是它们在程序中的实现过程。操作系统和编译器是根据程序运行的内存区域知道他们的,程序的全局数据放在所分配内存的全局数据区,程序的局部数据放在栈区。
7.8086是多少位的系统?在数据总线上是怎么实现的?
*8086是16微处理器,内部及对外有16位数据通路,8080/8085只有8位。 8086寻址空间1MB,8080/8085为64KB。8086有一个初级流水线结构,内部操作与对外操作具有并行性,8085无。 8086是个里程碑。
8086的机器字长是16位,8086使用40个引脚的16个做地址/数据复用引腿来传输数据,一次读写过程由一个基本总线周期完成,它由4个时钟(CLK)周期组成,按时间顺序定义为T1、T2、T3、T4。在T1期间8086发出访问目的地的地址信号和地址锁存选通信号ALE;T2期间发出读写命令信号RD、WR及其它相关信号;T3期间完成数据的访问;T4结束该总线周期。可见,地址与数据信号不会同时出现在一个时钟(CLK)周期,二者可以分时复用同一组引线。
大唐电信
DTT笔试题
考试时间一小时,第一部分是填空和选择:
1.数列6,10,18,32,“?”,问“?”是几?
2.某人出70买进一个x,80卖出,90买回,100卖出,这桩买卖怎么样?
3.月球绕地球一圈,至少要多少时间?
4.7个人用7小时挖了7米的沟,以同样的速度在50小时挖50米的沟要多少人?
5.鱼头长9,鱼尾等于鱼头加半个鱼身,鱼身等于鱼头加鱼尾,问鱼全长多少?
6.一个小姐买了一块手表,回家发现手表比她家的表慢了两分钟,晚上看新闻的时候又发现她家的表比新闻里的时间慢了两分钟,则 。
A 手表和新闻里的时间一样
B 手表比新闻里的时间慢
C 手表比新闻里的时间快
7.王先生看到一则招聘启事,发现两个公司除了以下条件不同外,其他条件都相同
A 半年年薪50万,每半年涨5万
B 一年年薪100万,每一年涨20万
王先生想去一家待遇比较优厚的公司,他会去哪家?
10.问哪个袋子里有金子?
A袋子上的标签是这样写的:B袋子上的话是对的,金子在A袋子。
B袋子上的标签是这样写的:A袋子上的话是错的,金子在A袋子里。
11.3个人住酒店30块钱,经理找回5块钱,服务生从中藏了2块钱,找给每人1块钱,3×(101)+2=29,问这是怎么回事?
12.三篇写作,均为书信形式。
(1)一片中文的祝贺信,祝贺某男当了某公司xx
(2)两篇英文的,一是说有事不能应邀,派别人去;另一篇是讨债的,7天不给钱就走人(主要考business letter格式)。
大唐面试试题
1.什么是中断?中断发生时CPU做什么工作?
所谓中断是指系统发生某一事件后,CPU暂停正在执行的程序转去执行处理该事件的程序过程,处理中断事件的程序称为中断处理程序,产生中断信号的那个部件称为中断源。硬件的中断机构与处理这些中断的程序统称为中断系统。
当中断发生时,硬件机构自动地进入响应中断过程,由操作系统的中断处理程序对中断事件进行处理,具体过程如下:
①.保存现场
系统开辟现场区,并将现场区组织成"栈"结构,当中断响应时,(1)硬件结构自动将PS和PC寄存器的内容压人栈中作为现场信息保存起来。(2)根据发生的中断,硬件从指定的中断向量单元中取出PS和PC内容,分别装人PS和PC寄存器,同时正确填人路寄存器的"当前状态"和"先前状态"字段。
②.分析原因,转中断处理程序
不同原因产生的中断事件要进行不同的处理,根据中断的路寄存器内容得出发生该种中断的具体原因。转人相对应的申断处理程序运行。
③.恢复现场
在多级中断系统中,考虑退回当前中断时,必须依据原先被中断的程序,完成不同的工作,中断处理结柬后,软件必须退出中断。如果此次是高级中断,并且被中断的程序是一个低级中断处理程序,则此次中断应返回到该低级中断处理程序。如果原来被中断的是用户程序,则退出中断前应先考虑进行一次调度选择,以挑选出更适合在当前情况下运行的新程序。
2.CPU在上电后,进入操作系统的main()之前必须做什么工作?
整个系统对开发环境以及各种变量的初始化,包括了变量空间的分配,cpu内部寄存器的初始化,总线的初始化等等,总之,只有等系统初始化完成以后,我们的c语言的main才能被识别和执行下来
3.简述ISO OSI的物理层Layer1,链路层Layer2,网络层Layer3的任务。
4.有线电话和无线电话有何区别?无线电话特别需要注意的是什么?
5.软件开发五个主要step是什么?
6.你在开发软件的时候,这5个step分别占用的时间百分比是多少?
7.makefile文件的作用是什么?
Makefile 的作用是根据配置的情况,构造出需要编译的源文件列表,然后分别编译,并把目标代码链接到一起,最终形成 Linux 内核二进制文件。
8.UNIX显示文件夹中,文件名的命令是什么?能使文件内容显示在屏幕的命令是什么?
ls。cat,more
9.(选做)手机用户在从一个基站漫游到另一个基站的过程中,都会发生什么?
原基站与手机用户之间的链路将由新基站与手机用户之间的链路取代的过程。
网通笔试题
选择题(每题5分,只有一个正确答案)
1.中国1号信令协议属于 的协议。
A ccs B cas C ip D atm
2.isdnpri协议全称是 。
A 综合业务模拟网基速协议
B 综合业务模拟网模拟协议
C 综合业务数字网基率协议
D 综合业务数字网基次协议
3.路由协议中, 协议是用距离作为向量的。
A ospf B bgp C is-is D rip
4.中国智能网中,ssp与scp间最上层的ss7协议是 。
A incs B is41b C is41c D inap
5.dtmf全称是 。
A 双音多频 B多音双频 C多音三频 D三音多频
6.计算机的基本组成部分中,不包含下面设备的是 。
A cpu B输入设备 C存储器 D接口
7.脉冲编码调制的简称是 。
A pcm B pam C (delta)M D atm
8.普通电话线接口专业称呼是 。
A rj11 B rj45 C rs232 D bnc
9.现有的公共数据网都采用 。
A电路交换技术 B报文交换技术
C语音插空 D分组交换
10.ss7协议中的制止市忙消息简写为 。
A stb B slb C sub D spb
简答题(每题10分)
1.简述普通电话与IP电话的区别。
2.简述随路信令与公路信令的根本区别。
3.说明掩码的主要作用。
4.ss7协议中,有三大要素决定其具体定位,哪三大要素?
5.描述ss7的基本通话过程。
6.简述通信网的组成结构。
7.面向连接与面向非连接各有何利弊?
8.写出爱尔兰的基本计算公式。
9.数据网主要有哪些设备?
10.中国一号协议是如何在被叫号码中插入主叫号码的?
东信笔试题目
笔试:30分钟。
1.压控振荡器的英文缩写。
2.动态随机存储器的英文缩写。
3.选择电阻时要考虑什么?
4.单片机上电后没有运转,首先要检查什么?
5.计算机的基本组成部分及其各自的作用。
6.怎样用D触发器、与或非门组成二分频电路?
中软融鑫笔试题
1.关于工作
(1) 你对未来的工作生活是怎样憧憬的?为何选择我公司作为求职公司?
(2)请用不超过30个字给出一个最能让我们录用你的理由。
(3)你认为比较理想的工作环境是怎样的?
(4)你个人的中长期的职业发展目标是怎样的?
2.关于社会
(1)如果你是杨利伟,你在太空中向祖国人民说的第一句话是什么?
(2)宋美龄女士于2003年10月谢世,对这位著名人士在西安事变中的态度和作用,你是如何看待的?(不超过300字)
(3)北京政府颁布的对拾金不昧者,失主要奖励相当于财产20%奖金的公告,你是如何看的?
(4)如果给你50万元人民币,你将会用这些钱做什么?
(5)在美国,男、女卫生间(厕所)的正确称呼为什么?请用英语写出答案。
(6)你认为麦当劳是世界最大的汉堡生产商吗?如果不是,请说出你的观点。
3.教育背景
(1)你受过哪些正规的教育或培训?(自高中毕业起)
(2)在校期间进行过哪些社会活动?
Delphi笔试题目
机械类笔试试题
1. Briefly describe what is blanking(cutting), forming, coining and embossing in stamping process.
2. What is metal clading?
3. What is the purpose of adding glass fiber to thermoplastic material?
4. In contrast with metal and thermoplastic material,which has a higher coefficient of thermal expansion(CTE).
5. The most suitable material for a integral hinge design (typical plastic thickness=0.25 to 0.5mm at hinge)
6. Can a bending load makes both compressive and tensile stress in a member?
7. What is the design criteria used in plastics catch/snap?
8. What is FEA?
9. Why is natural frequency important in vibration analysis?
10. What is the deflection equation of a cantilever beam fixed at one edge?
EE笔试试题
1. Name 3 Vehicle Buses.
2. Name 2 possible sources of Electromagnetic interference on Electronics Circuit ASM.
3. Wavelength for 12MHz frequency signal is____
4. Name 2 important considerations for car radio performan -ce related to audio signal processing under multipath condition?
5. What is the typical FM receiver RF signal strength to achieve 30dB S/N for car radio?
6. When a radio is tuned to 98.1 MHz & with a LO of 108.8 MHz, what is the image frequency?
7. For a system with a matched impedance, what is the Reflection Coefficient and SWR?
8. Which property of the output capacitor is the primary cause of Low Drop Out(LDO) regulator loop instability?
(1)Equivalent series resistance(ESR)
(2)Effective series inductance(ESL)
(3)Capacitance value
(4)Dielectric material
9. The switching regulator is capable of:
(1)Higher power conversion efficiency
(2)Providing an output voltage that is higher than the input
(3)Generating an output boltage oppsite in polarity to the input
(4)All of the above
10. A linear regulator op Vin(max) = 10v, Vout(min) = 4.8v, Iout(max) = 2.5mA, Iq(max) = 2.5mA, Ta(max) = 8.5摄氏度,The regulator is available in 3 packages.Each package has the following thermal characteristics:
Package Rja(摄氏度/W) Rjc(摄氏度/W)
SO14 125 30
D1P8 100 52
Choose the most suitable package to handle the power dissipation requirement without a heat sink and why.
软件笔试题
1. How do you code an infinite loop in C?
2. Volatile:
(1)What does the keyword volatile mean? Give an example
(2)Can a parameter be both const and volatile? Give an example
(3)Can a pointer be volatile? Give an example
3. What are the values of a, b, and c after the following instructions:
int a=5, b=7, c;
c = a+++b;
4. What do the following declarations mean?
(1)const int a;
(2)int const a;
(3)const int *a;
(4)int * const a;
(5)int const * a const;
5. Which of the following statements describe the use of the keyword static?
(1)Within the body of a function: A static variable maintains its value between function revocations
(2)Within a module: A static variable is accessible by all functions within that module
(3)Within a module: A static function can only be called by other functions within that module
6. Embedded systems always require the user to manipulate bits in registers or variables. Given an integer variable a, write two code fragments.
The first should set bit 5 of a. The second shnuld clear bit 5 of a. In both cases, the remaining bits should be unmodified.
7. What does the following function return?
char foo(void)
{
unsigned int a = 6;
iht b = -20;
char c;
(a+b > 6) ? (c=1): (c=0);
return c;
}
8. What will be the output of the following C code?
main()
{
int k, num= 30;
k =(num > 5 ? (num <=10 ? 100:200): 500);
printf(“%d”, k);
}
9. What will the following C code do?
int *ptr;
ptr =(int *)Ox67a9;
*ptr = Oxaa55;
10. What will be the output of the follow C code?
#define product(x) (x*x)
main()
{
int i = 3, j, k;
j = product(i++);
k = product(++i);
printf(“%d %d”,j,k);
}
11. Simplify the following Boolean expression
!((i ==12) || (j > 15))
12. How many flip-flop circuits are needed to divide by 16?
13. Provides 3 properties that make an OS, a RTOS?
14. What is pre-emption?
15. Assume the BC register value is 8538H, and the DE register value is 62A5H.Find the value of register BC after the following assembly operations:
MOV A,C
SUB E
MOV C,A
MOV A,B
SBB D
MOV B,A
16. In the Assembly code shown below
LOOP: MVI C,78H
DCR C
JNZ LOOP
HLT
How many times is the DCR C Operation executed?
17. Describe the most efficient way (in term of execution time and code size) to divide a number by 4 in assembly language
18. what value is stored in m in the following assembly language code fragment if n=7?
LDAA #n
LABEL1: CMPA #5
BHI L3
BEQ L2
DECA
BRA L1
LABEL2: CLRA
LABEL3: STAA #m
19. What is the state of a process if a resource is not available?
#define a 365*24*60*60
20. Using the #define statement, how would you declare a manifest constant that returns the number of seconds in a year? Disregard leap years in your answer.
21. Interrupts are an important part of embedded systems. Consequently, many compiler vendors offer an extension to standard C to support interrupts. Typically, the keyword is __interrupt. The following routine (ISR). Point out problems in the code.
__interrupt double compute_area (double radius)
{
double area = PI * radius * radius;
printf(“\nArea = %f”, area);
return area;
}
Hongkong Bank笔试题
1. Please state why you chose to follow these activities and how they have contributed to your personal development. You may wish to give details of your role whether anyone else was involved and any difficulties you encountered.
2. Please state how you have benefited from your work experience.
3. How much is your present monthly salary including allowances.
4. Do you need to compensate your present employer if you resign? If so, please give details.
5. Other than academic success, what has been your greatest achievement to date? What do you see as your personal strength, why?
6. Please state why the position you have applied for is appropriate for you; Why you have selected HongKong Bank and what your career objectives are.
A.T. Keaney笔试题
1. Describe your greatest achievement in the past 4-5 years?
2. What are your short-term and long-term career objectives? What do you think is the most ideal job for you?
3. Why do you want to join A.T kearney? What do you think you can contribute to A.T kearney?
4. Why are you applying for a position at Arthur Anderson?
5. What are your expectations of our firm.
6. Describe your hobbies and interests.
Shell company笔试题
1. How wold your colleagues/classmates describe you in five words? On what evidence would they base this assessment.
2. If you are asked to recruit the best graduates for shell, what would you do to attract them? What would you do to select them?
3. Please describe a new activity that you have initiated and implemented.Please highlight your role out.
4. Please describe your outstanding non-academic achieve- ments.
5. Please describe any other significant activities you have been involved in including organizing people.
6. Imagine that Shell has found oil in an inland province of China, near a large river. You are responsible for planning how to transport the oil to the coast thousands of miles away. What are the main issue you would consider, and what would you do?
KPMG笔试题
“The big economic difference between nuclear and fossil-fuelled power stations is that nuclear reactors are more expensive to build and decommission, but cheaper to sun. So disputes over the relative efficiency of the two systems revolve not just around prices of coal and uranium today and tomorrow, but also around the way in which future income should be compared with current income.”
1. The main difference between nuclear and fossil-fuelled power stations is an economic one.
TRUE
UNTRUE
CANNOT SAY
2. The price of coal is not relevant to discussions about the relative efficiency of nuclear reactors.
TRUE
UNTRUE
CANNOT SAY
3. If nuclear reactors were cheaper to build and decommission than fossil-fuelled power stations, they would definitely have the economic advantage.
TRUE
UNTRUE
CANNOT SAY
“At any given moment we are being bombarded by physical and psychological stimuli competing for our attention. Although our eyes are capable of handling more than 5 million bits of data per second, our brain are capable of interpreting only about 500 bits per second. With similar disparities between each of the other senses and the brain, it is easy to see that we must select the visual, auditory, or tactile stimuli that we wish to compute at any specific time.”
4. Physical stimuli usually win in the competition for our attention.
TRUE
UNTRUE
CANNOT SAY
5. The capacity of the human brain is sufficient to interpret nearly all the stimuli the senses can register under optimum conditions.
TRUE
UNTRUE
CANNOT SAY
6. Eyes are able to cope with a greater input of information than ears.
TRUE
UNTRUE
CANNOT SAY
VERBAL ANSWER:
(1)C CANNOT SAY
(2)B UNTRUE
(3)A TRUE
(4)C CANNOT SAY
(5)B UNTRUE
(6)C CANNOT SAY
PartII NUMERCAL TEST
1.Which country had the highest number of people aged 60 or over at the start of 1985?
A. UK
B. France
C. Italy
D. W.Germany
E. Spain
2.What percentage of the total 15mm button production was classed as sub-standard in September?
AA 10.5% BB 13% CC 15% DD 17.5% EE 20% AB 23.5% AC 25%
AD 27.5% AE 28% BC 30.5%
3. How many live births occurred in 1985 in Spain and Italy together (to the nearest 1000)?
A. 104 000
B. 840 000
C. 1 044 000
D. 8 400 000
E. 10 440 000
4. What was the net effect on the UK population of the live birth and death rates in 1985?
A. Decrease of 66 700
B. Increase of 752 780
C. Increase of 84 900
D. Cannot Say
E. Increase of 85 270
5. By how much did the total sales value of November‘s button production vary from October‘s?
A. 8.50 (Decrease)
B. 42.50 (Decrease)
C. 85.00 (Increase)
D. 27.50 (Decrease)
E. No change
6. What was the loss in potential sales revenue attributable to the production of sub-standard (as opposed to standard) buttons over the 6 month period?
A. 13.75
B. 27.50
C. 137.50
D. 280.00
E. 275.00
香港电信笔试题
1. Based on your understanding of the following java related technologies: servlets, JavaServerPage, JavaBeans, Enterprise JavaBeans, how do you think these technologies are work together or are applied in the development of an internet-based application (25marks).
2. In your opinion ,what do you think are the advantages or benefitsof using an object-oriented approach to software development? how do you think those benefits can be achieved or realized? (15marks).
3. In designing your classes, given the choice between inheritance and aggregation which do you choose (15marks).
4. How would you work around the lack of multiple inheritance feature in Java (15marks).
5. What would you consider to be the hardest part of OO analysis and design and why (10marks).
6. How do you keep yourself up to date with the latest in software techonogy, especially in the field of software development (10marks).
7. What si your career aspiration? Why do you think this E-Commerce Development Center can help you in achieving your career goals (10marks) (1hr, answer in English).
L\‘ORÉAL的笔试题
1. Would you please describe yourself in 3-4 lines? (limited in 500 words)
2. Could you tell us why we should choose you as a Loreal Person, and what makes you unique? (limited in 500 words)
3. What is your short-term and long-term career plan? (limited in 500 words)
4. What kind of group activities are you interested in and what type of role do you often play? (limited in 500 words)
5. Please use one sentence to give a definition of ‘Beauty’, and describe the most beautiful thing in your life. (limited in 500 words)
维尔VERITAS软件笔试题
1. A class B network on the internet has a subnet mask of 255.255.240.0, what is the maximum number of hosts per subnet .
a. 240 b. 255 c. 4094 d. 65534
2. What is the difference: between o(log n) and o(log n^2), where both logarithems have base 2 .
a. o(log n^2) is bigger b. o(log n) is bigger
c. no difference
3. For a class what would happen if we call a class’s constructor from with the same class’s constructor .
a. compilation error b. linking error
c. stack overflow d. none of the above
4. “new” in c++ is a: .
a. library function like malloc in c
b. key word c. operator
d. none of the above
5. Which of the following information is not contained in an inode .
a. file owner b. file size
c. file name d. disk address
6. What’s the number of comparisons in the worst case to merge two sorted lists containing n elements each .
a. 2n b.2n-1 c.2n+1 d.2n-2
7. Time complexity of n algorithm T(n), where n is the input size ,is T(n)=T(n-1)+1/n if n>1 otherwise 1 the order of this algorithm is .
a. log (n) b. n c. n^2 d. n^n
8. The number of 1’s in the binary representation of 3*4096+ 15*256+5*16+3 are .
a. 8 b. 9 c. 10 d. 12
百威啤酒(武汉公司)
1,为什么申请来百威?
2,将来有什么打算?
3,有没有社会活动经历?
4,有没有当众演讲的经历?
5,经常使用那些软件?
6,喜欢哪些课程?
7,你认为工作中的什么因素对你来说最重要?
8,什么时候可以来上班?可以在这里工作多久?
9,八点上班,要加班和出差,能不能做到?
星巴克
1、 您是一家咖啡店的店经理,你发现店内同时出现下列状况:
1)许多张桌子桌面上有客人离去后留下的空杯未清理,桌面不干净待整理。
2)有客人正在询问店内卖哪些品种,他不知如何点咖啡菜单。
3)已有客人点完成咖啡,正在收银机旁等待结帐。
4)有厂商正准备要进货,需要店经理签收。
请问,针对上述同时发生的情况,你要如何排定处理之先后顺序,为什么
2、 有一位甲员工脾气不好以致在前三家店因为与店内其他同事相处不佳而屡屡调动,现在甲被调到你的店里面来,请问身为店经理的你,将如何应对??
3、 你是店经理,本周五结帐后,发现门市总销售额较上周五减少30%,请问可能原因会是哪几种,各原因如何应对?
凹凸电子软件笔试题
1. Select ONE of the following projects to discuss:
a. Signal Filtering: You are given a sampled realtime waveform consisting of a sensor reading mixed with highly periodic impulses and high frequency noise.The desired output is the realtime filtered sensor signal with the impulses and noise removed, and a readout of the impulse period. The FFT may not be used.
b. Interrupt Processing.A headware register consisting of eight independent edge triggered latches is used to record external asynchronous interrupt requests. When any of the request bits are latched, a software interrupt is generated. The software may read the latch to see which interrupt(s) occurred. Writing a one to any latch bit will clear the latch. How does that software assure that no interrupt request is ever missed?
c. User Interface: a prototype MP3 player interface consisting of a playlist display and a few control buttons is given to you. How would you make the interface “skinnable”,with user selected graphics, options, and control button placement?
Each project description is incomplete. What questions would you ask to completely specify the project? What development tools would you prefer to use? What algorithm /data structures/design would you use?
2. What program(s) have you coded for you own enjoyment (not part of a school project,not for pay). What type of software project would you most enjoy working on?
3. Have you participated in a team programming project? What is the hardest part of programming as a team, as opposed to programming alone?
友立资讯笔试题目
1.一堆鸡蛋,3个3个数剩余2个,5个5个数剩余1个,7个7个数剩余3个,问这堆鸡蛋最少有多少个?并给出通解。
2.列举五岳,及其所在省份。
3.何为四书。
4.按顺序默写24节气。
5.默写于谦的《吟石灰》。
6.英语翻译约300字。
7.作文一篇:求职有感。
普华永道PWC笔试题目(作文)
1.最近10年来中国媒体的变化。
2.你认为发展汽车产业和公共交通哪个更重要?
3.如何理解风险投资?
4.如何理解广告的消极作用和积极作用?
Avant! 微电子EE笔试题
1.名词解释:VLSI,CMOS,EDA,VHDL,Verilog,HDL,ROM,RAM,DRC,LVS。
2.简述CMOS工艺流程。
3.画出CMOS与非门的电路,并画出波形图简述其功能。
4.画出N沟道增强型MOSFET的剖面图。
5.简述ESD和latch-up的含义。
6.简述三极管与MOS管的区别。
7.简述MOORE模型和MEALY模型。
8.简述堆栈与队列的区别。
奇码数字信息有限公司笔试题
1.画出NMOS的特性曲线(指明饱和区,截至区,线性区,击穿区和C-V曲线)
2.2.2um工艺下,Kn=3Kp,设计一个反相器,说出器件尺寸。
3.说出制作N-well的工艺流程。
4.雪崩击穿和齐纳击穿的机理和区别。
5.用CMOS画一个D触发器(clk,d,q,q-)。
德勤笔试题
五个人来自不同地方,住不同房子,养不同动物,吸不同牌子香烟,喝不同饮料,喜欢不同食物。根据以下线索确定谁是养猫的人。
(1)红房子在蓝房子的右边,白房子的左边(不一定紧邻)
(2)黄房子的主人来自香港,而且他的房子不在最左边。
(3)爱吃比萨饼的人住在爱喝矿泉水的人的隔壁。
(4)来自北京的人爱喝茅台,住在来自上海的人的隔壁。
(5)吸希尔顿香烟的人住在养马的人右边隔壁。
(6)爱喝啤酒的人也爱吃鸡。
(7)绿房子的人养狗。
(8)爱吃面条的人住在养蛇的人的隔壁。
(9)来自天津的人的邻居(紧邻)一个爱吃牛肉,另一个来自 成都。
(10)养鱼的人住在最右边的房子里。
(11)吸万宝路香烟的人住在吸希尔顿香烟的人和吸“555”香烟的人的中间(紧邻)
(12)红房子的人爱喝茶。
(13)爱喝葡萄酒的人住在爱吃豆腐的人的右边隔壁。
(14)吸红塔山香烟的人既不住在吸健牌香烟的人的隔壁,也不与来自上海的人相邻。
(15)来自上海的人住在左数第二间房子里。
(16)爱喝矿泉水的人住在最中间的房子里。
(17)爱吃面条的人也爱喝葡萄酒。
(18)吸“555”香烟的人比吸希尔顿香烟的人住的靠右。
扬智(科技)笔试题目
软件题目
1. Queue is a useful structure
* What is a queue?
* Write 5 operations or functions, without details, that can be done on a queue.
2. Insert a sequence fo keys(24,49,13,20,59,23,90,35) into a data structure, which has no keys initially. Depict the data structure after these insertions, if it is:
* a heap tree
* an AVL tree
3. * What is a synchronous I/O bus?
* What is an asnchronous I/O bus?
* Compare the advantages and disadvantages of synchronous and a synchronous I/O bus.
4. Explain the following terminology:
* Baud rate
* Handshaking
* Memory mapped I/O
5. Explain the key issues in supporting a real-time operation system for embedded system.
6. Explain the mapping of visual addresses to real addresses under paging by
* direct mapping
* associative mapping
* combined direct/associated mapping
7. Please explain what is “write-back” and “write-through”, and discuss the advantage and disadvantage about these two methods.
8. Explain the concept and benefit of threads
9. What is hardware interrupt? What is software interrupt? What is exception? Please tell me all you know about interrupt.
10. Write a recursive function that tests wether a string is a palindrome. A palindrome is s string such as “abcba” or “otto” that reads the same in both directions.If you can write this function recursively,you can write an iterative version of this function instead.
11.什么是进程(Process)和线程(Thread)?有何区别?
12.MFC和SDK有何区别?
13.IRP是什么?有何作用?
14.Windows 2000操作系统下用户模式和内核模式下编程有何区别?
15.驱动程序的BUFFER能swap到磁盘上去吗?为什么?
16.试编写3个函数实现
(1)建立一个双向链表
(2)插入一个节点
(3)删除一个节点
17.简述Hardware interrupt和software中断的区别,简述其应用。
18.试编写一个函数,计算一个字符串中A的个数。
19.画出其相应流程图并编写一个函数实现一个整数到二进制数的转换,如输入6,输出110。
20.
(1)编写一个递归函数,删除一个目录。
(2)编写一个非递归函数,删除一个目录。
并比较其性能。
21.附加题:简单叙述编程经历
硬件题目
1.用mos管搭出一个二输入与非门。
2.集成电路前段设计流程,写出相关的工具。
3.解释名词IRQ,BIOS,USB,VHDL,SDR。
4.简述如下Unix命令cp -r, rm,uname。
5.用波形表示D触发器的功能。
6.写异步D触发器的verilog module。
7.What is PC Chipset?
8.用传输门和倒向器搭一个边沿触发器。
9.画状态机,接受1,2,5分钱的卖报机,每份报纸5分钱。
DSP题目
1.H(n)a*h(n1)+b*δ(n)
(1)求h(n)的z变换
(2)该系统是否为稳定系统
(3)写出FIR数字滤波器的差分方程
2.写出下面模拟信号所需的最小采样带宽
(1)模拟信号的频率范围是0~4kHz
(2)模拟信号的频率范围是2~4kHz
3.名词解释
(1)量化误差
(2)直方图
(3)白平衡
(4)MMX
4.写出下面几种格式中用到的压缩技术
(1)JPEG
(2)MPEG2
(3)MP3
高通笔试题
1. Can you describe the trend of wireless mobile communication industry? (2000 letters)
2. Compare the major third generation technologies.(2000 letters)
3. Describe the characteristics of Walsh function. Explain how to generate Walsh Function. (2000 letters)
4. List factors that will affect the capacity of forward and reverse links of a CDMA system. (2000 letters)
5. What are the differences between IS-95 A/B and cdma2000 1X? (2000 letters)
威盛笔试试题
2002年软件笔试题
1.三组程序,找出你认为的错误。
(1)a.c long temp[255];
b.c extern *temp;
(2)a.c long temp[255];
b.c extern temp[256];
(3)a.c long temp[255];
b.c extern temp[];
2.在第一个声明处编译出了奇怪的错误,为什么?
#include <stdio.h>
#include “myfun1.h”
#include “myfun2.h”
int myInt1;
int myInt2;
3.printf(“0x%x”, (&0)[1]); 请问打印了什么?
4.汇编,用ax,bx,cx,dx,求1000×1000/30(四舍五入),结果放在ax中。
5.编最优化Bubble(int *pIntArray,int L),要求:交换元素不能用临时变量,如果有序需要最优。
6.用任意一种编程语言写n!的算法。
2003 Asic部分
1.一个四级的Mux,其中第二级信号为关键信号,如何改善timing?
2.一个状态机的题目用Verilog实现。
3.Asic中的design flow的实现。
4.用逻辑门画出D触发器。
5.给出某个一般时序电路的图,有Tsetup,Tdelay,Tck>q还有clock的delay,写出决定最大时钟的因素,同时给出表达式。
6.用C语言实现统计某个cell在某.v文件调用的次数。
7.Cache的主要部分。
2003 EE笔试题目
1.写出电流公式。
2.写出平板电容公式。
3.电阻R和电容C串联,输入电压为R和C之间的电压,输出电压分别为C上电压和R上电压,要求绘制这两种电路输入电压的频谱,判断这两种电路何为高通滤波器,何为低通滤波器。当RC<<T时,给出输入电压波形图,绘制两种电路的输出波形图。
4.给出时域信号,求其直流分量。
5.给出一时域信号,要求写出频率分量,并写出其傅立叶变换级数。当波形经过低通滤波器滤掉高次谐波而只保留一次谐波时,画出滤波后的输出波形。
6.有一时域信号S=V0sin(2pif0t)+V1cos(2pif1t)+V2sin(2pif3t+90),写出当其通过低通、带通、高通滤波器后的信号表示方式。
7.给出一差分电路,告诉其输出电压Y+和Y,求共模分量和差模分量。
8.一电源和一段传输线相连(长度为L,传输时间为T),画出终端处波形,考虑传输线无损耗。给出电源电压波形图,要求绘制终端波形图。
9.求锁相环的输出频率,给了一个锁相环的结构图。
10.给出一个堆栈的结构,求中断后显示结果,主要是考堆栈压入返回地址存放在低端地址还是高端。
2003 Graphic笔试题目
1.问答题
(1)texture mapping是什么?为什么要用filter?
(2)用float和int表示一个数,比如2,说明优点和缺点。
(3)在MPEG哪部分可以加速硬件?
(4)解释cubic和B-spline的差别,写出各自函数。
(5)写出几个Win API中的OpenGL函数。
(6)说出固定小数表示和浮点小数表示的优缺点。
(7)说出显卡可以优化哪些MPEG中的计算?
(8)说出Bezier和B-Spline曲线的区别。
2.用最简单的方法判断一个数是否是2的指数次幂。
3.S23E8和S10E5两种浮点数表示方法分析,表示0.25写一个类S10E5,实现从S23E8转换。
4.用模版的方式实现三个量取最大值。
5.题目告诉你IEEE 16和32浮点数表示的规范,要求将0.25分别用IEEE 16和32表示并写一个C++函数将输入的IEEE 16表示转化为IEEE 32的表示。
6.用C语言写一个函数f(x) x * 0.5要求只能用整数操作。
2003 Software Engineer笔试题
1. Describe x86 PC’s architecture in a diagram cpu,core chipset, Cache,DRAM, IO-subsystem, IO-Bus
2. SWI instruction is often called a “supervisor call”, describe the actions in detail
* Save the address of the instruction after the SWI in rl4_svc.
* Save the CPSR in SPSR_svc.
* Enter supervisor mode and disable IRQs.
* Set the PC to 08 and begin executing the instruction there.
3.
* What is PIO operation? advantage and disadvantage?
* DMA operation? advantage and disadvantage?
* Scatter/Gather DMA engine? how does it operate?
4. MP3 decoder related. (a flow chart of decoding is presented)
* advantages of Huffman encoding?
* why the aliasing reduction is necessary?
* analytical expression in mathematics of the IMDCT?
* which block in the flow chart is suitable for the software implementation and which for the hardware? why?
5. Assembly codes -> C language (about 15 lines).
6. Graduation thesis description.
汉王笔试题
高级研究人员(模式识别、图像处理类)招聘试题
说明:
可能您的专业并不完全符合本试题所涉及的领域。因此,并非所有的问题都需要回答,您可以只回答你所熟悉和能够回答的问题。允许参考任意的资料,但请独立完成此试题,我们更欣赏您独立的思考和创新的精神。本试题并非我们录用或者不录用您的惟一依据。应聘高级研究人员者请回答这部分问题。
1.人工智能与模式识别的研究已有多年,但似乎公认的观点认为它仍然非常困难。试对你所熟悉的任一方向(如指纹识别、人像识别、语音识别、字符识别、自然语言理解等)的发展状况进行描述。并设想如果你将从事该方向的研究,你打算如何着手,以建立有效的识别理论和方法;或者你认为现在的理论和方法有何缺陷,有什么办法来进行改进?(500字以内即可,不要太长)
2.简述下面任一主题的主要理论框架或主要观点(500字以内即可,不要太长)
(1)David Marr的视觉计算理论框架
(2)格式塔(Gestalt)心理学派的主要观点
(3)Bayes决策理论
(4)人工神经网络中的BP网络、自组织网络和联想记忆网络的主要内容
(5)基因算法
(6)小波分析
(7)目前流行的有损静态图像压缩方法
3.设想你要设计一个算法,检测给定的图像中是否有矩形结构。所要检测的矩形可能有多种形态,试提出你的算法框架。要求你的算法至少能检测出样本中的矩形,而拒绝其他的任意非矩形结构。矩形的大小、位置和方向未知,要求你的算法能确定这些参数。
如果你认为这个问题太难而不能解决,请说明理由。
高级软件开发人员招聘试题
说明:
可能您的专业并不完全符合本试题所涉及的领域。因此,并非所有的问题都需要回答,您可以只回答你所熟悉和能够回答的问题。允许参考任意的资料,但请独立完成此试题,我们更欣赏您独立的思考和创新的精神。本试题并非我们录用或者不录用您的惟一依据。
应聘高级软件开发人员者请回答这部分问题。
1.数据的逻辑存储结构(如数组,队列,树等)对于软件开发具有十分重要的影响,试对你所了解的各种存储结构从运行速度、存储效率和适用场合等方面进行简要地分析。
2.数据库技术是计算机系统中一个非常重要的领域,几乎所有的计算机应用中都或多或少地用到了数据库。试简要地谈谈数据库设计中应当注意哪些问题,以及如何解决?给出两种你所熟悉的DBMS,要求一种适用于小型应用,另一种适用于大型应用,给出你做出选择的理由。
3.某公司的主要业务是提供WWW和E-mail服务,出于安全考虑,该公司要求我公司提供一套网络指纹登录系统,该系统要求能够利用指纹替代E-mail中常用的密码,并对所提供的部分网页通过指纹认证后才能访问,请利用你所学过的知识对该系统进行分析设计,你可以指定网络的配置(包括协议),但必须保证邮件用户既可通过网页(http方式)收取信件,也可通过Outlook收取信件。请分析该系统的可行性,可行时给出系统结构和主要的存储结构,指出系统中的难点和解决方法。(假设指纹识别的问题已经解决)
高级硬件开发人员招聘试题
说明:
可能您的专业并不完全符合本试题所涉及的领域。因此,并非所有的问题都需要回答,您可以只回答你所熟悉和能够回答的问题。允许参考任意的资料,但请独立完成此试题,我们更欣赏您独立的思考和创新的精神。本试题并非我们录用或者不录用您的惟一依据。
应聘高级硬件开发人员者请回答这部分问题。
1.下面是一些基本的数字电路知识问题,请简要回答:
(1)什么是Setup和Holdup时间?
(2)什么是竞争与冒险现象?怎样判断?如何消除?
(3)请画出用D触发器实现2倍分频的逻辑电路。
(4)什么是“线与”逻辑?要实现它,在硬件特性上有什么具体要求?
(5)什么是同步逻辑和异步逻辑?
(6)请画出微机接口电路中,典型的输入设备与微机接口逻辑示意图(数据接口、控制接口、所存器/缓冲器)。
(7)你知道哪些常用的逻辑电平?TTL与COMS电平可以直接互连吗?
2.可编程逻辑器件在现代电子设计中越来越重要,请问:
(1)你所知道的可编程逻辑器件有哪些?
(2)试用VHDL或Verilog,ABLE描述8位D触发器逻辑
3.设想你将设计完成一个电子电路方案。请简述用EDA软件(如PROTEL)进行设计(包括原理图和PCB图)到调试出样机的整个过程。在各个环节应注意哪些问题?
北京信威通信技术股份有限公司面试题
1.DSP和通用处理器在结构上有什么不同?请简要画出你熟悉的一种DSP结构图。
2.说说定点DSP和浮点DSP的定义(或者说出他们的区别)。
3.说说你对循环寻址和位反序寻址的理解。
4.请写出【8,7】的二进制补码和二进制偏置码。用Q15表示出0.5和0.5。
中国国际金融有限公司CICC笔试题
1. Please tell us about an achievement that you are especially proud of because it was difficult or demanding.
(1)What the objective was?
(2)Why it is important to you?
(3)How you achieved it and the obstacles that you had to overcome in order to do so?
2. What is your career plan? Three years after graduation, and five years after graduation?
3. Why are you interested in investment bank? What other industries do you also have interests?
4. Why do you think you can be a qualified investment banker? How can you contribute in this industry?
国泰君安笔试题
一列火车上有三个工人,史密斯、琼斯和罗伯特,三人工作为消防员、司闸员和机械师,有三个乘客与这三人的名字相同。罗伯特住在底特律;司闸员住在芝加哥和底特律中间的地方;琼斯一年赚2万美金;有一个乘客和司闸员住在一个地方,每年的薪水是司闸员的3倍整;史密斯台球打得比消防员好;和司闸员同名的乘客住在芝加哥。
请问谁是机械师?
Briny笔试题
1.说出RC振荡器的构成和工作原理。
2.什么是SDH?
3.什么是共模、差模?画出差分电路的结构。
4.a=5; b=6; a+=b++; 执行结果是什么?
5.什么是TDM?什么是CDMA?
6.什么是采样定理?
7.什么是香农定理?
8.计算机的中断有哪几类?
广东北电面试题目
英文笔试题
1. Tranlation (Mandatory)
CDMA venders have worked hard to give CDMA roaming capabilities via the development of RUIM-essentially, a SIM card for CDMA handsets currently being deployed in China for new CDMA operator China Unicom. Korean cellco KTF demonstrated earlier this year the ability to roam between GSM and CDMA using such cards.However,only the card containing the user’s service data can roam-not the CDMA handset or the user’s number (except via call forwarding).
2. Programming (Mandatory)
Linked list
a. Implement a linked list for integers,which supports the insertafter (insert a node after a specified node) and removeafter (remove the node after a specified node) methods;
b. Implement a method to sort the linked list to descending order.
3. Debugging (Mandatory)
a. For each of the following recursive methods,enter Y in the answer box if themethod terminaters (assume i=5), Otherwise enter N.
static int f(int i){
return f(i-1)*f(i-1);
}
Ansewr:
static int f(int i){
if(i==0){return 1;}
else {return f(i-1)*f(i-1);}
}
Ansewr:
static int f(int i){
if(i==0){return 1;}
else {return f(i-1)*f(i-2);}
}
Ansewr:
b. There are two errors in the following JAVA program:
static void g(int i){
if(i==1){return;}
if(i%2==0){g(i/2);return;}
else {g(3*i);return;}
}
please correct them to make sure we can get the printed-out result as below:
3 10 5 16 8 4 2 1
中文笔试题
1.汉译英
北电网络的开发者计划使来自于不同组织的开发者,能够在北电网络的平台上开发圆满的补充业务。北电网络符合工业标准的开放接口,为补充业务的开展引入了无数商机,开发者计划为不同层面的开发者提供不同等级的资格,资格的划分还考虑到以下因素:补充业务与北电网络平台的集合程度,开发者团体与北电网络的合作关系,等等。
2.编程
将整数转换成字符串:void itoa(int,char);
例如itoa(-123,s[])则s=“-123”;
U2合唱团在17分钟内得赶到演唱会场,途中必需跨过一座桥,四个人从桥的同一端出发,你得帮助他们到达另一端,天色很暗,而他们只有一只手电筒。一次同时最多可以有两人一起过桥,而过桥的时候必须持有手电筒,所以就得有人把手电筒带来带去,来回桥两端。手电筒是不能用丢的方式来传递的。四个人的步行速度各不同,若两人同行则以较慢者的速度为准。Bono需花1分钟过桥,Edge需花2分钟过桥,Adam需花5分钟过桥,Larry需花10分钟过桥。他们要如何在17分钟内过桥呢?(有个同济的学生写文章说他当时在微软面试时就是碰到了这道题,最短只能做出在19分钟内过桥,微软的人对他讲这样的结果已经是不错的了!)
A点到B点
1和2过去 2分钟 2
2过来 4分钟 2+2=4
10和5过去 14分钟 4+10=14
1过来 15分钟 14+1=15
1和2过去 17分钟 15+2=17
19分钟还很不错????
广州本田笔试题
1.排序s-m-t-w-t-f-?
2.如果六千,六百,六表示成6606,那么十一千,十一百,十一表示成什么?
3.grass后面加一个词,agent前面加一个单词,组成两个新词,这个词是什么?
4.农场不知道有多少鸡,现有一批饲料,如果卖掉75只鸡饲料够20天用,买进100只鸡饲料够用15天,问原来有多少只鸡?
5.6个桶,装着两种液体,一种液体的价格是另外一种的double,桶容量为8,13,15,17,19,31,有一个美国人,各用了14美元买两种液体,剩下一个桶。问剩下哪个?
6.篮球场,还剩6秒,差对手4分,没可能追得上,现在有一个暂停,你会怎么指导球员去做?
明基面试问题
1.自我介绍(2分钟)。
2.你大学期间最辉煌的一件事是什么?
3.如果你明天去火星呆上300年,今天晚上你最想做的一件事是什么?
网易
1、10个人分成4组 有几种分法?
2、如图:
7 8 9 10
6 1 2 11
5 4 3 12
16 15 14 13
设“1”的坐标为(0,0) “7”的坐标为(-1,-1) 编写一个小程序,使程序做到输入坐标(X,Y)之后显示出相应的数字。
3、#include<stdio.h>
//example input and output
//in 1 2 3 out 1 3 1
//in 123456789 2 100 out 123456789 100 21
long mex(long a,long b,long c)
{ long d;
if(b==0) return 0;
if(b==1) return a%c;
d=mex(a,b/2,c); d*=d;这里忘了;d*=mex(a,b%2,c);d%=c;
return d;
}
int main(void)
{ long x,y,z;
while(1)
{ if(scanf(%d %d %d,&x,&y,&z)>3) return 0;
if(x<0) { printf("too small\n");continue;}
if(y<0) { printf("too small\n");continue;}
if(z<1) { printf("too small\n");continue;}
if(y>z) { printf("too big\n");continue;}
if(z>1000000010) {printf("too big\n");continue}
printf(%d %d %d,x,z,mex(x,y,z);
}}
根据这个程序,当已知一个输入,算出输出,如:输入 1 3 1 则输出 1 2 3 输入 123456789 100 21 输出 123456789 2 100
广州日报
1、填空部分是一些时事题,如:我国有多少网民,三个代表、北京申奥什么的,及记者的一些常识性的问题:如我国第一个以写新闻通讯出名的记者是谁?蔡元培曾经夸奖过的记者是谁?
2、选择题范围与填空基本一样,包括时政和新闻知识:如深度采访的实质,记者的职业道德等。
3、简答题就比较专业:一道是你参加一条高速公路的开通典礼,如何在记者会上发的新闻通稿之外写出会上没说的内容。一道是你去一个单位采访,但没有任何该单位的证件、邀请函之类东西,你如何骗过门卫混进去。第三道是有几家香水公司都想让你说好话,就是做软新闻了,你该如何处理。第四道是A明星与B明星不和,你如何报道A骂B的话而又不能让B告你诽谤。
4、写作题是以“今年冬天不太冷”为题任意想象,加叙加议。
5、五道智力测验:如何喝道啤酒杯底部的啤酒、汽车过隧道但高2厘米该怎么办、你吃苹果时吃到几条虫最恶心之类,10只点燃的蜡烛,让风吹灭了2只,后来在关窗户前又吹灭1只。问最后还有几支。
对数组,指针,数据结构,算法,字符串,文件操作等问题都有覆盖.主要以c语言的实现为主,也有c++的题.大家可以先做做这10道题,测试一下自己的水平.
1. 下面这段代码的输出是多少(在32位机上).
char *p;
char *q[20];
char *m[20][20];
int (*n)[10];
struct MyStruct
{
char dda;
double dda1;
int type ;
};
MyStruct k;
printf("%d %d %d %d",sizeof(p),sizeof(q),sizeof(m),sizeof(n),sizeof(k));
答案:4,80,1600,4,24
n是指向一维数组的指针变量;k中不要忘了考虑对齐问题,这里dda为4个字节。
2.
(1)
char a[2][2][3]={{{1,6,3},{5,4,15}},{{3,5,33},{23,12,7}} };
for(int i=0;i<12;i++)
printf("%d ",_______);
在空格处填上合适的语句,顺序打印出a中的数字
答案:a[i/6][(i/3)%2][i%3];这道题目是多维数组的输出问题,这里要考虑的是每维数字的取值顺序问题:第一维,前六次循环都取0,后六次取1,于是i/6可以满足要求;第二维,前3次为0,再3次为1,再3次为0,再3次为1,用量化的思想,i/3把12个数字分为4组每组3个,量化为0、1、2、3,为要得到0、1、0、1我们这里就需要对(0、1、2、3)%2=(0、1、0、1),于是(i/3)%2;最后一维我们需要的是(0、1、2;0、1、2;0、1、2;0、1、2;)我们就i%3。
(2)
char **p, a[16][8];
问:p=a是否会导致程序在以后出现问题?为什么?
答案:这个不会导致出现问题,但是要注意p的使用,如a[1][2] 等价的为 *(*(p+1)+2)而不是*(p+11),
3.用递归方式,非递归方式写函数将一个字符串反转.
函数原型如下:char *reverse(char *str);
答案:
非递归方式:
char *reverse(char *str)
{
int len = strlen(str);
char temp;
for(int i=0; i<len/2; i++)
{
temp = *(str+i);
*(str+i) = *(str+len-1-i);
*(str+len-1-i) = temp;
}
return str;
}
递归方式:???
4.strcpy函数和memcpy函数有什么区别?它们各自使用时应该注意什么问题?
答案:strcpy是字符串拷贝,遇 '\0' 则停。
memcpy是内存拷贝,要指定拷贝的长度。
当要拷贝二进制数据(比如说一个结构),只能用memcpy
5.写一个函数将一个链表逆序.
一个单链表,不知道长度,写一个函数快速找到中间节点的位置.
写一个函数找出一个单向链表的倒数第n个节点的指针.(把能想到的最好算法写出).
答案:
把一个链表中的接点顺序倒排
typedef struct linknode
{
int data;
struct linknode *next;
}node;
//将一个链表逆置
node *reverse(node *head)
{
node *p,*q,*r;
p=head;
q=p->next;
while(q!=NULL)
{
r=q->next;
q->next=p;
p=q;
q=r;
}
head->next=NULL;
head=p;
return head;
}
6.用递归算法判断数组a[N]是否为一个递增数组。
7.
有一个文件(名为a.txt)如下,每行有4项,第一项是他们的名次,写一个c程序,将五个人的名字打印出来.并按名次排序后将5行数据仍然保存到a.txt中.使文件按名次排列每行.
2,07010188,0711,李镇豪,
1,07010154,0421,陈亦良,
3,07010194,0312,凌瑞松,
4,07010209,0351,罗安祥,
5,07010237,0961,黄世传,
8.写一个函数,判断一个unsigned char 字符有几位是1.
写一个函数判断计算机的字节存储顺序是升序(little-endian)还是降序(big-endian).
9.微软的笔试题.
Implement a string class in C++ with basic functionality like comparison, concatenation, input and output. Please also provide some test cases and using scenarios (sample code of using this class).
Please do not use MFC, STL and other libraries in your implementation.
10.有个数组a[100]存放了100个数,这100个数取自1-99,且只有两个相同的数,剩下的98个数不同,写一个搜索算法找出相同的那个数的值.(注意空间效率时间效率尽可能要低).
这十道题还是能够看出自己的水平如何的.如果你能不假思索地做出这10道题,估计去国外大公司是没有问题了,呵呵.
答案我在整理中,以后陆续发布.................
下面有些题也不错,可以参考.
1.下面的代码输出是什么,为什么?
void foo(void)
{
unsigned int a = 6;
int b = -20;
(a+b>6)?puts(">6"):puts("<=6");//puts为打印函数
}
输出 >6.
就是考察隐式转换.int型变量转化成unsigned int, b成了正数.
2. b)运行下面的函数会有什么结果?为什么?
void foo(void)
{
char string[10],str1[10];
int i;
for(i=0;i<10;i++)
{
str1[i] = 'a';
}
strcpy(string, str1);
printf("%s",string);
}
首先搞清strcpy函数的实现方法,
char * strcpy(char * strDest,const char * strSrc)
{
if ((strDest == NULL) || (strSrc == NULL))
throw "Invalid argument(s)";
char * strDestCopy = strDest;
while ((*strDest++ = *strSrc++) != '\0');
return strDestCopy;
}
由于str1末尾没有‘\0’结束标志,所以strcpy不知道拷贝到何时结束.
printf函数,对于输出char* 类型,顺序打印字符串中的字符直到遇到空字符(’\0’)或已打印了由精度指定的字符数为止.
下面是微软的两道笔试题....
3. Implement a string class in C++ with basic functionality like comparison, concatenation, input and output. Please also provide some test cases and using scenarios (sample code of using this class).
Please do not use MFC, STL and other libraries in your implementation.
我的实现方案如下,这道题真地对c++的主要特性都进行了较好地考察.
String.h:
#ifndef STRING_H
#define STRING_H
#include <iostream>
using namespace std;
class String{
public:
String();
String(int n,char c);
String(const char* source);
String(const String& s);
//String& operator=(char* s);
String& operator=(const String& s);
~String();
char& operator[](int i){return a[i];}
const char& operator[](int i) const {return a[i];}//对常量的索引.
String& operator+=(const String& s);
int length();
friend istream& operator>>(istream& is, String& s);//搞清为什么将>>设置为友元函数的原因.
//friend bool operator< (const String& left,const String& right);
friend bool operator> (const String& left, const String& right);//下面三个运算符都没必要设成友元函数,这里是为了简单.
friend bool operator== (const String& left, const String& right);
friend bool operator!= (const String& left, const String& right);
private:
char* a;
int size;
};
#endif
String.cpp:
#include "String.h"
#include <cstring>
#include <cstdlib>
String::String(){
a = new char[1];
a[0] = '\0';
size = 0;
}
String::String(int n,char c){
a = new char[n + 1];
memset(a,c,n);
a[n] = '\0';
size = n;
}
String::String(const char* source){
if(source == NULL){
a = new char[1];
a[0] = '\0';
size = 0;
}
else
{ size = strlen(source);
a = new char[size + 1];
strcpy(a,source);
}
}
String::String(const String& s){
size = strlen(s.a);//可以访问私有变量.
a = new char[size + 1];
//if(a == NULL)
strcpy(a,s.a);
}
String& String::operator=(const String& s){
if(this == &s)
return *this;
else
{
delete[] a;
size = strlen(s.a);
a = new char[size + 1];
strcpy(a,s.a);
return *this;
}
}
String::~String(){
delete[] a;//
}
String& String::operator+=(const String& s){
int j = strlen(a);
int size = j + strlen(s.a);
char* tmp = new char[size+1];
strcpy(tmp,a);
strcpy(tmp+j,s.a);
delete[] a;
a = tmp;
return *this;
}
int String::length(){
return strlen(a);
}
main.cpp:
#include <iostream>
#include "String.h"
using namespace std;
bool operator==(const String& left, const String& right)
{
int a = strcmp(left.a,right.a);
if(a == 0)
return true;
else
return false;
}
bool operator!=(const String& left, const String& right)
{
return !(left == right);
}
ostream& operator<<(ostream& os,String& s){
int length = s.length();
for(int i = 0;i < length;i++)
//os << s.a[i];这么不行,私有变量.
os << s[i];
return os;
}
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[i] = c;
i++;
/*if(i >= 20){
cout << "Input too much characters!" << endl;
exit(-1);
}*/
if(i == m - 1 ){
s.a[i] = '\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[i] = '\0';
return is;
}
int main(){
String a = "abcd";
String b = "www";
//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 << "a < b" << endl;
else
cout << "a >= b" << endl;
if(e == a)
cout << "e == a" << endl;
else
cout << "e != a" << endl;
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 <stdio.h>
#include <ctype.h>
int myAtoi(const char* s){
int result = 0;
int flag = 1;
int i = 0;
while(isspace(s[i])) //isspace 测试字符是否为空格字符
i++;
if(s[i] == '-'){
flag = -1;
i++;
}
if(s[i] == '+')
i++;
while(s[i] != '\0'){
if((s[i] > '9') || (s[i] < '0'))
break;
int j = s[i] - '0';
result = 10 * result + j;
i++;
}
result = result * flag;
return result;
}
int main(){
char* a = " -1234def";
char* b = "+1234";
int i = myAtoi(a);
int j = myAtoi(b);
printf("%d \n",i);
printf("%d",j);
return 0;
}
2.int i=(j=4,k=8,l=16,m=32); printf(“%d”, i); 输出是多少?
3.解释局部变量、全局变量和静态变量的含义。
4.解释堆和栈的区别。
一、预备知识—程序的内存分配
一个由c/C++编译的程序占用的内存分为以下几个部分
1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。
2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。
3、全局区(静态区)(static)—,全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域, 未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 - 程序结束后有系统释放
4、文字常量区 —常量字符串就是放在这里的。 程序结束后由系统释放
5、程序代码区—存放函数体的二进制代码。
二、例子程序
这是一个前辈写的,非常详细
//main.cpp
int a = 0; 全局初始化区
char *p1; 全局未初始化区
main()
{
int b; 栈
char s[] = "abc"; 栈
char *p2; 栈
char *p3 = "123456"; 123456\0在常量区,p3在栈上。
static int c =0; 全局(静态)初始化区
p1 = (char *)malloc(10);
p2 = (char *)malloc(20);
分配得来得10和20字节的区域就在堆区。
strcpy(p1, "123456"); 123456\0放在常量区,编译器可能会将它与p3所指向的"123456"优化成一个地方。
}
二、堆和栈的理论知识
2.1申请方式
stack:
由系统自动分配。 例如,声明在函数中一个局部变量 int b; 系统自动在栈中为b开辟空间
heap:
需要程序员自己申请,并指明大小,在c中malloc函数
如p1 = (char *)malloc(10);
在C++中用new运算符
如p2 = (char *)malloc(10);
但是注意p1、p2本身是在栈中的。
2.2
申请后系统的响应
栈:只要栈的剩余空间大于所申请空间,系统将为程序提供内存,否则将报异常提示栈溢出。
堆:首先应该知道操作系统有一个记录空闲内存地址的链表,当系统收到程序的申请时, 会遍历该链表,寻找第一个空间大于所申请空间的堆结点,然后将该结点从空闲结点链表中删除,并将该结点的空间分配给程序,另外,对于大多数系统,会在这块内存空间中的首地址处记录本次分配的大小,
这样,代码中的delete语句才能正确的释放本内存空间。另外,由于找到的堆结点的大小不一定正好等于申请的大小,系统会自动的将多余的那部分重新放入空闲链表中。
2.3申请大小的限制
栈:在Windows下,栈是向低地址扩展的数据结构,是一块连续的内存的区域。这句话的意思是栈顶的地址
和栈的最大容量是系统预先规定好的,在WINDOWS下,栈的大小是2M(也有的说是1M,总之是一个编译时就确定的常数),如果申请的空间超过栈的剩余空间时,将提示overflow。因此,能从栈获得的空间较小。
堆:堆是向高地址扩展的数据结构,是不连续的内存区域。这是由于系统是用链表来存储的空闲内存地址的,自然是不连续的,而链表的遍历方向是由低地址向高地址。堆的大小受限于计算机系统中有效的虚拟内存。由此可见,堆获得的空间比较灵活,也比较大。
2.4申请效率的比较:
栈由系统自动分配,速度较快。但程序员是无法控制的。
堆是由new分配的内存,一般速度比较慢,而且容易产生内存碎片,不过用起来最方便.
另外,在WINDOWS下,最好的方式是用VirtualAlloc分配内存,他不是在堆,也不是在栈是直接在进程的地址空间中保留一快内存,虽然用起来最不方便。但是速度快,也最灵活。
2.5堆和栈中的存储内容
栈: 在函数调用时,第一个进栈的是主函数中后的下一条指令(函数调用语句的下一条可执行语句)的地址,然后是函数的各个参数,在大多数的C编译器中,参数是由右往左入栈的,然后是函数中的局部变量。注意静态变量是不入栈的。
当本次函数调用结束后,局部变量先出栈,然后是参数,最后栈顶指针指向最开始存的地址,也就是主函数中的下一条指令,程序由该点继续运行。
堆:一般是在堆的头部用一个字节存放堆的大小。堆中的具体内容有程序员安排。
2.6存取效率的比较
char s1[] = "aaaaaaaaaaaaaaa";
char *s2 = "bbbbbbbbbbbbbbbbb";
aaaaaaaaaaa是在运行时刻赋值的;
而bbbbbbbbbbb是在编译时就确定的;
但是,在以后的存取中,在栈上的数组比指针所指向的字符串(例如堆)快。
比如:
#include
void main()
{
char a = 1;
char c[] = "1234567890";
char *p ="1234567890";
a = c[1];
a = p[1];
return;
}
对应的汇编代码
10: a = c[1];
00401067 8A 4D F1 mov cl,byte ptr [ebp-0Fh]
0040106A 88 4D FC mov byte ptr [ebp-4],cl
11: a = p[1];
0040106D 8B 55 EC mov edx,dword ptr [ebp-14h]
00401070 8A 42 01 mov al,byte ptr [edx+1]
00401073 88 45 FC mov byte ptr [ebp-4],al
第一种在读取时直接就把字符串中的元素读到寄存器cl中,而第二种则要先把指针值读到edx中,在根据edx读取字符,显然慢了。
堆和栈的区别及内存泄露- -