- 相關(guān)推薦
廣東北電面試題
下面是廣東北電的筆試題(中英文題),這套題早已在網(wǎng)絡(luò)上流傳數(shù)年,從來(lái)只見(jiàn)題目,不見(jiàn)解答,那就讓我做做吧。英文搞得不對(duì)的地方那就沒(méi)辦法了。
一:英文題。
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).
翻譯:CDMA開(kāi)發(fā)商一直致力于RUIM卡的開(kāi)發(fā),以此賦予CDMA漫游的能力。RUIM卡類(lèi)似于SIM卡,事實(shí)上目前它已經(jīng)被中國(guó)的CDMA運(yùn)營(yíng)商中國(guó)聯(lián)通廣泛使用。韓國(guó)手機(jī)制造企業(yè)KTF今年早些時(shí)候展示了使用此種卡在GSM和CDMA網(wǎng)絡(luò)中漫游的功能,但是,只有該卡包含的用戶服務(wù)數(shù)據(jù)能夠漫游,CDMA手機(jī)本身及用戶號(hào)碼則不能(除了呼叫前轉(zhuǎn)業(yè)務(wù))。
呵呵。上文可能翻譯的不太精準(zhǔn),歡迎批評(píng)。
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.
答:題目的意思是實(shí)現(xiàn)一個(gè)整型鏈表,支持插入,刪除操作(有特殊要求,都是在指定節(jié)點(diǎn)后進(jìn)行操作),并寫(xiě)一個(gè)對(duì)鏈表數(shù)據(jù)進(jìn)行降序排序的方法。
那我們不妨以一個(gè)線性鏈表進(jìn)行編程。
// 單鏈表結(jié)構(gòu)體為
typedef struct LNode
{
int data;
struct LNode *next;
}LNode, *pLinkList;
// 單鏈表類(lèi)
class LinkList
{
private:
pLinkList m_pList;
int m_listLength;
public:
LinkList();
~LinkList();
bool InsertAfter(int afternode, int data);//插入
bool RemoveAfter(int removenode);//刪除
void sort();//排序
};
實(shí)現(xiàn)方法
//insert a node after a specified node
bool LinkList::InsertAfter(int afternode, int data)
{
LNode *pTemp = m_pList;
int curPos = -1;
if (afternode > m_listLength ) // 插入點(diǎn)超過(guò)總長(zhǎng)度
{
return false;
}
while (pTemp != NULL) // 找到指定的節(jié)點(diǎn)
{
curPos++;
if (curPos == afternode)
break;
pTemp = pTemp->next;
}
if (curPos != afternode) // 節(jié)點(diǎn)未尋到,錯(cuò)誤退出
{
return false;
}
LNode *newNode = new LNode; // 將新節(jié)點(diǎn)插入指定節(jié)點(diǎn)后
newNode->data = data;
newNode->next = pTemp->next;
pTemp->next = newNode;
m_listLength++;
return true;
}
//remove the node after a specified node
bool LinkList::RemoveAfter(int removenode)
{
LNode *pTemp = m_pList;
int curPos=-1;
if (removenode > m_listLength) // 刪除點(diǎn)超過(guò)總長(zhǎng)度
{
return false;
}
// 找到指定的節(jié)點(diǎn)后一個(gè)節(jié)點(diǎn),因?yàn)閯h除的是后一個(gè)節(jié)點(diǎn)
while (pTemp != NULL)
{
curPos++;
if (curPos == removenode+1)
break;
pTemp = pTemp->next;
}
if (curPos != removenode) // 節(jié)點(diǎn)未尋到,錯(cuò)誤退出
{
return false;
}
LNode *pDel = NULL; // 刪除節(jié)點(diǎn)
pDel = pTemp->next;
pTemp->next = pDel->next;
delete pDel;
m_listLength--;
return true;
}
//sort the linked list to descending order.
void LinkList::sort()
{
if (m_listLength<=1)
{
return;
}
LNode *pTemp = m_pList;
int temp;
// 選擇法排序
for(int i=0;i
for(int j=i+1;j
if (pTemp[i].data
{
temp=pTemp[i].data;
pTemp[i].data=pTemp[j].data;
pTemp[j].data=temp;
}
}
前兩個(gè)函數(shù)實(shí)現(xiàn)了要求a,后一個(gè)函數(shù)sort()實(shí)現(xiàn)了要求b
3. Debugging (Mandatory)
a. For each of the following recursive methods, enter Y in the answer box if the method terminaters (assume i=5), Otherwise enter N.
(題目意思:判斷下面的遞歸函數(shù)是否可以結(jié)束)
static int f(int i){
return f(i-1)*f(i-1);
}
Ansewr: N,明顯沒(méi)有返回條件語(yǔ)句,無(wú)限遞歸了
static int f(int i){
if(i==0){return 1;}
else {return f(i-1)*f(i-1);}
}
Ansewr:Y,當(dāng)i=0時(shí)可結(jié)束遞歸
static int f(int i){
if(i==0){return 1;}
else {return f(i-1)*f(i-2);}
}
Ansewr:N,因?yàn)閕=1時(shí),f(i-2)=f(-1),進(jìn)入一個(gè)無(wú)限遞歸中
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
答:在第一個(gè)if語(yǔ)句前加 System.out.print(i+" ");
else 里面的g(3*i)改為g(3*i+1)
【廣東北電面試題】相關(guān)文章:
Microsoft面試題09-04
iOS面試題07-10
公司面試題09-12
hibernate面試題10-18
英語(yǔ)面試題精選06-13
小升初面試題06-10
PHP面試題10-14
小升初面試題型08-24
小升初面試題類(lèi)型07-23
關(guān)于網(wǎng)管面試題07-27