夏普 2021 技術崗面試題
小編:管理員 1498閱讀 2021.10.11
兩個人依次拋硬幣,最先拋出正面的人獲勝,求第一個人獲勝的概率,給出分析過程
第2題:
求一個實數的指數值,a^b,補充完整下面的代碼。
double exponention(double a, unsigned long b)
{
double c=1.0;
while(b)
{ if(b&1)c*=a;
a=_a*a______________;
b=_b>>1______________;
}
return c;
}
第3題:
判斷兩個矩形是否相交,不相交,返回0,相交則返回相交的面積。
struct rect
{
int left;
int right;
int top;
int bottom
};
int intersection(rect A, rect B)
{
}
提示:
求兩個矩形的最大左邊值,最大上底值,最小右邊值,最小下底值,
即maxleft, maxtop, minright, minbottom;
如果maxleft>minright || maxtop > minbottom,則兩個矩形相交,否則不相交
int intersection(rect A, rect B)
{ int maxleft, maxtop,minright, minbottom;
maxleft=A->left > B->left?A->left:B->left;
maxtop=A->top > B->top?A->top:B->top;
minright=A->right right?A->right : B->right;
minbottom=A->bottom bottom? A->bottom : B-> bottom;
if(maxleft>minright || maxtop> minbottom)return 0;
else return (minright -maxleft)*(minbottom-maxtop);
}
第4題:
寫一個遞歸函數交換一顆二叉樹的左右子樹
第5題:
一個整型數組包含N個整數,其中有3個整數出現的次數均大于N/4,找出這3個數,并分析時間復雜度。
相關推薦
- 烽火 2021 技術面試題 第1題:iso七層協議,以及每次有哪些協議。第2題:兩個ip地址為192.168.0.1/23和192.168.1.1/23 能不能互相通信。如果不能說明為什么,應該怎么修改,才能互相通信 第3題:ATM,FPGA,TCP/IP,FIFO,FSM解釋 第4題:FPGA CPLD結構 第5題:FPGA開發過程和工具 第6題…
- 2022年美團騎手要求、工資、每單價格,美團面試題(持續更新) 一、面試要求: 1、對于入職美團騎手來說,崗位要求是非常低的,只需滿足一定條件即可。而且對于目前美團騎手的要求只有一個,那就是只要您身體健康,有健康證,年齡在18-50周歲之間,有一部智能手機,就可以申請成為美團騎手; 2、能熟練使用智能手機; 3、有…