C/C++笔试题(11)
(慧通)
1 寫出程序把一個鏈表中的接點順序倒排
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;
}
2 寫出程序刪除鏈表中的所有接點
void del_all(node *head)
{ node *p;
?while(head!=NULL)
?{ p=head->next;
?? free(head);
?? head=p;
?}
?cout<<"釋放空間成功!"<<endl;
?}
3兩個字符串,s,t;把t字符串插入到s字符串中,s字符串有足夠的空間存放t字符串
void insert(char *s, char *t, int i)
{
char *q = t;
char *p =s;
if(q == NULL)return;
while(*p!='/0')
{
p++;
}
while(*q!=0)
{
*p=*q;
p++;
q++;
}
*p = '/0';
}
void insert(char *s, char *t, int i)
{
memcpy(&s[strlen(t)+i],&s[i],strlen(s)-i);
memcpy(&s[i],t,strlen(t));
s[strlen(s)+strlen(t)]='/0';
}
分析下面的代碼:
char *a = "hello";
char *b = "hello";
if(a= =b)
printf("YES");
else
printf("NO");
這個簡單的面試題目,我選輸出 no(對比的應該是指針地址吧),可在VC是YES 在C是NO
lz的呢,是一個常量字符串。位于靜態存儲區,它在程序生命期內恒定不變。如果編譯器優化的話,會有可能a和b同時指向同一個hello的。則地址相同。如果編譯器沒有優化,那么就是兩個不同的地址,則不同
?
?
寫一個函數,功能:完成內存之間的拷貝
memcpy source code:
270 void* memcpy( void *dst, const void *src, unsigned int len )
271 {
272 register char *d;
273 register char *s;
27
275 if (len == 0)
276 return dst;
277
278 if (is_overlap(dst, src, len, len))
279 complain3("memcpy", dst, src, len);
280
281 if ( dst > src ) {
282 d = (char *)dst + len - 1;
283 s = (char *)src + len - 1;
284 while ( len >= 4 ) {
285 *d-- = *s--;
286 *d-- = *s--;
287 *d-- = *s--;
288 *d-- = *s--;
289 len -= 4;
290 }
291 while ( len-- ) {
292 *d-- = *s--;
293 }
294 } else if ( dst < src ) {
295 d = (char *)dst;
296 s = (char *)src;
297 while ( len >= 4 ) {
298 *d++ = *s++;
299 *d++ = *s++;
300 *d++ = *s++;
301 *d++ = *s++;
302 len -= 4;
303 }
304 while ( len-- ) {
305 *d++ = *s++;
306 }
307 }
308 return dst;
309 }
公司考試這種題目主要考你編寫的代碼是否考慮到各種情況,是否安全(不會溢出)
各種情況包括:
1、參數是指針,檢查指針是否有效
2、檢查復制的源目標和目的地是否為同一個,若為同一個,則直接跳出
3、讀寫權限檢查
4、安全檢查,是否會溢出
memcpy拷貝一塊內存,內存的大小你告訴它
strcpy是字符串拷貝,遇到'/0'結束
/* memcpy ——— 拷貝不重疊的內存塊 */
void memcpy(void* pvTo, void* pvFrom, size_t size)
{
void* pbTo = (byte*)pvTo;
void* pbFrom = (byte*)pvFrom;
ASSERT(pvTo != NULL && pvFrom != NULL); //檢查輸入指針的有效性
ASSERT(pbTo>=pbFrom+size || pbFrom>=pbTo+size);//檢查兩個指針指向的內存是否重疊
while(size-->0)
*pbTo++ == *pbFrom++;
return(pvTo);
}
華為面試題:
?
怎么判斷鏈表中是否有環?
bool CircleInList(Link* pHead)
{
if(pHead = = NULL || pHead->next = = NULL)//無節點或只有一個節點并且無自環
return (false);
if(pHead->next = = pHead)//自環
return (true);
Link *pTemp1 = pHead;??? //step 1
Link *pTemp = pHead->next;?? //step 2
while(pTemp != pTemp1 && pTemp != NULL && pTemp->next != NULL)
{
pTemp1 = pTemp1->next;?? //增量1
pTemp = pTemp->next->next;? //增量2
}
if(pTemp = = pTemp1)
return (true);
return (false);
}
1。編寫一個 C 函數,該函數在一個字符串中找到可能的最長的子字符串,且該字符串是由同一字符組成的。
char * search(char *cpSource, char ch)
{
char *cpTemp=NULL, *cpDest=NULL;
int iTemp, iCount=0;
while(*cpSource)
{
if(*cpSource == ch)
{
iTemp = 0;
cpTemp = cpSource;
while(*cpSource == ch)
++iTemp, ++cpSource;
if(iTemp > iCount)
iCount = iTemp, cpDest = cpTemp;
if(!*cpSource)
break;
}
++cpSource;
}
return cpDest;
}
2。請編寫一個 C 函數,該函數在給定的內存區域搜索給定的字符,并返回該字符所在位置索引值。
int search(char *cpSource, int n, char ch)
{
int i;
for(i=0; i<n && *(cpSource+i) != ch; ++i);
return i;
}
一個單向鏈表,不知道頭節點,一個指針指向其中的一個節點,問如何刪除這個指針指向的節點?
將這個指針指向的next節點值copy到本節點,將next指向next->next,并隨后刪除原next指向的節點。
#include <stdio.h>
void foo(int m, int n)
{
printf("m=%d, n=%d/n", m, n);
}
int main()
{
int b = 3;
foo(b+=3, ++b);
printf("b=%d/n", b);
return 0;
}
輸出:m=7,n=4,b=7(VC6.0)
這種方式和編譯器中得函數調用關系相關即先后入棧順序。不過不同
編譯器得處理不同。也是因為C標準中對這種方式說明為未定義,所以
各個編譯器廠商都有自己得理解,所以最后產生得結果完全不同。
因為這樣,所以遇見這種函數,我們首先要考慮我們得編譯器會如何處理
這樣得函數,其次看函數得調用方式,不同得調用方式,可能產生不同得
結果。最后是看編譯器優化。
2.寫一函數,實現刪除字符串str1中含有的字符串str2.
第二個就是利用一個KMP匹配算法找到str2然后刪除(用鏈表實現的話,便捷于數組)
?
大唐電信
DTT筆試題
考試時間一小時,第一部分是填空和選擇:
1.數列6,10,18,32,“?”,問“?”是幾?
2.某人出70買進一個x,80賣出,90買回,100賣出,這樁買賣怎么樣?
80+100-70-90=20? 盈利20
3.月球繞地球一圈,至少要多少時間?
4.7個人用7小時挖了7米的溝,以同樣的速度在50小時挖50米的溝要多少人?
7v7=7;? ?v50=50;兩式相比?=7人
5.魚頭長9,魚尾等于魚頭加半個魚身,魚身等于魚頭加魚尾,問魚全長多少?
3元一次不等式 簡單
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×(101)+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 is41cD 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 Crs232 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.中國一號協議是如何在被叫號碼中插入主叫號碼的?
中軟融鑫筆試題
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.5mmat 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 inassembly 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 15mmbutton 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 inSpain 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
總結
以上是生活随笔為你收集整理的C/C++笔试题(11)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux资源查看命令详解大全[top|
- 下一篇: C++ 虚基类