1. 首頁
  2. 面試

應屆大學生面試技巧嵌入式方面3

應屆大學生面試技巧嵌入式方面(3)

作為一個即將畢業的大學生,在外地實習找工作確實是一件很痛苦的事情,我們沒有很強的技能(除過那些很BT的傢伙),沒有一定的社會閱歷,甚至沒有一點家庭背景.但是作為企業來說,他們在很大程度上也都是很瞭解應屆大學生的,他們對我們的要求不是很高,除非有的公司是想刁難你,但是這樣的事情是很少發生的,

我就我在北京的一些找工作的經驗和學習到的一些知識分享給大家,僅代表一家之言,不足之處請大家指正.

 

操作篇:發些程式碼給大家做做筆試參考.

1.下面的程式碼輸出是什麼,為什麼?

void foo(void)
{ unsigned int a = 6;
int b = -20;
(a+b > 6) puts("> 6") : puts("<= 6");

}

2.評價下面的程式碼片斷:

unsigned int zero = 0;
unsigned int compzero = 0xFFFF;

對於一個int型不是16位的處理器為說,上面的程式碼是不正確的。應編寫如下:

unsigned int compzero = ~0;

3.求輸出char *ptr;
if ((ptr = (char *)malloc(0)) == NULL)
puts("Got a null pointer");
else
puts("Got a valid pointer");

4.C語言同意一些令人震驚的結構,下面的.結構是合法的嗎,如果是它做些什麼?
int a = 5, b = 7, c;
c = a+++b;

5.What will print out?

main()
{ char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%sn”,p2);

}

Answer:empty string.

What will be printed as the result of the operation below:

main()
{ int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);
}

Answer : 5794

What will be printed as the result of the operation below:

main()
{ int x=5;
printf(“%d,%d,%dn”,x,x<<2,x>>2);
}

Answer: 5,20,1

What will be printed as the result of the operation below:

#define swap(a,b) a=a+b;b=a-b;a=a-b;
void main()
{ int x=5, y=10;
swap (x,y);
printf(“%d %dn”,x,y);
swap2(x,y);
printf(“%d %dn”,x,y);
}

int swap2(int a, int b)
{ int temp;
temp=a;
b=a;
a=temp;
return 0;

}

Answer: 10, 5
10, 5

What will be printed as the result of the operation below:

main()
{ char *ptr = ” Cisco Systems”;
*ptr++; printf(“%sn”,ptr);
ptr++;
printf(“%sn”,ptr);
}

Answer:Cisco Systems
isco systems

What will be printed as the result of the operation below:

main()
{ char s1[]=“Cisco”;
char s2[]= “systems”;
printf(“%s”,s1);
} Answer: Cisco

What will be printed as the result of the operation below:

main()
{ char *p1;
char *p2;
p1=(char *)malloc(25);
p2=(char *)malloc(25);

strcpy(p1,”Cisco”);
strcpy(p2,“systems”);
strcat(p1,p2);

printf(“%s”,p1);

}

Answer: Ciscosystems

The following variable is available in file1.c, who can access it?:

static int average;

Answer: all the functions in the file1.c can access the variable.

WHat will be the result of the following code?

#define TRUE 0 // some code
while(TRUE)
{

// some code

}

Answer: This will not go into the loop as TRUE is defined as 0.

What will be printed as the result of the operation below:

int x;
int modifyvalue()
{ return(x+=10);
} int changevalue(int x)
{ return(x+=1);
}

void main()
{ int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%dn",x);

x++;
changevalue(x);
printf("Second output:%dn",x);
modifyvalue();
printf("Third output:%dn",x);

}

Answer: 12 , 13 , 13

What will be printed as the result of the operation below:

main()
{ int x=10, y=15;
x = x++;
y = ++y;
printf(“%d %dn”,x,y);
}

Answer: 11, 16

What will be printed as the result of the operation below:

main()
{ int a=0;
if(a==0)
printf(“Cisco Systemsn”);
printf(“Cisco Systemsn”);
}

Answer: Two lines with “Cisco Systems” will be printed.

再次更新C++相關題集

6. 以下三條輸出語句分別輸出什麼?[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; // 輸出什麼? 0
cout << boolalpha << ( str3==str4 ) << endl; // 輸出什麼? 0
cout << boolalpha << ( str5==str6 ) << endl; // 輸出什麼? 1

7.寫一個函式,反映出電腦是大端儲存(BIG_ENDER)還是小端儲存(LITTLE_ENDER)?

8.不用庫函式,編寫函式strcmp()和strcat() strcpy()

9.折半查詢函式?

10.int fun(int *p)和int fun(int p)區別?

11.struct

{

bit a;

char b;

int c;

float d;

}a;

求sizeof(a)=?

12.int main(int argc,char *argv[])
{
int c=9,d=0;
c=c++%5;
d=c;
printf("d=%d\n",d);
return 0;
}
a) 寫出程式輸出
5
b) 在一個可移植的系統中這種表示式是否存在風險?why?
13 .# include "stdio.h"
int a=0;
int b;
static char c;
int main(int argc,char *argv[])
{
char d=4;
static short e;

a++;
b=100;
c=(char)++a;
e=(++d)++;
printf("a=%d, b=%d, c=%d, d= %d, e=%d",a,b,c,d,e);
return 0;
}
a) 寫出程式輸出
以前學過c++,這個是可以的 e=(++d)++;
現在才發現在c中,這是不行的
a=2, b=100, c=2, d= 6, e=5
b) 編譯器如果安排各個變數(a,b,c,d)在記憶體中的佈局(eg. stack,heap,data section,bss section),最好用圖形方式描述。
data section: a
bss section: b,c,e
stack d
在採用段式記憶體管理的架構中,資料段(data segment)通常是指用來存放程式中已初始化的全域性變數的一塊記憶體區域。資料段屬於靜態記憶體分配。

在採用段式記憶體管理的架構中,BSS段(bss segment)通常是指用來存放程式中未初始化的全域性變數的一塊記憶體區域。BSS是英文Block Started by Symbol的簡稱。BSS段屬於靜態記憶體分配。