深圳易高科技有限公司面试题目

本文探讨了编程中常见的性能瓶颈及优化方法,包括使用更高效的数据结构、改进算法逻辑以及采用内置函数等手段来提高程序运行效率。通过具体案例分析,如字符串反转、货币代码转换等,展示了如何进行代码重构以实现更好的性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >













RecruitmentQuiz

PaperA






PrepareBy

2GoTradeLtd.

Version:
1.0

6Jan2006

Pleasecompletethefollowing
8questionswithin2hours.

Question
1

TheVB
Function,()function,GetCurrencyCodedemonstratesthetranslationbetweenthecurrencycodeandcurrencynumber.However,theperformanceofthisFunctionis()functionisnotgoodenough;thehigherorderofinputnumbertakesmuchmoretimestocalculate.Pleasesuggestawaytoimprovetheprogramperformance:

FunctionGetCurrencyCode()FunctionGetCurrencyCode(ByValinputAsString)AsString
Ifinput="01"Then
return="AFA"
ElseIfinput="02"Then
return="ALL"
ElseIfinput="03"Then
return="DZD"
ElseIfinput="04"Then
return="USD"
ElseIfinput="05"Then
return="HKD"
ElseIfinput="75"Then
return="EUR"
ElseIfinput="76"Then
return="XCD"
ElseIfinput="77"Then
return="AMD"
EndIf
EndFunction


Answer:
FunctionGetCurrencyCode()FunctionGetCurrencyCode(ByValinputAsString)AsStringSelectCaseinputCase"01":
return="AFA"Case"02":
return="ALL"Case"03":
return="DZD"Case"04":
return="USD"Case"05":
return="HKD"
Case"75":
return="EUR"
Case"76":
return="XCD"
Case"77":
return="AMD"
CaseElse:
return="unknown"EndSelectEndFunction



Question
2

WriteaFunctionthat()functionthatreversestheorderofthewordsinastring.Forinstance,yourFunctionshould()functionshouldtransformthestringDoordonot,thereisnotry.”Totry.Noistherenot,doorDo”.Assumethatallwordsarespacedelimitedandtreatpunctuationthesameasletters.

Useyourmosthands
-onprogramminglanguage.

Answer:

JavaScriptVersion:
FunctionReversesOrder()functionReversesOrder()
{
varOldStr
="Doordonot,thereisnotry."
varNewStr
="";
varArrayStr
=OldStr.split("");

for(vari=ArrayStr.length-1;i>=0;i--)
{
NewStr
+=ArrayStr[i]+"";
}
returnNewStr;
}
Question
3

StudythefollowingVBprogram:

ImportsSystem
ImportsSystem.IO
ModuleModule1ModuleModule1
PublicArtListAsArrayList
EndModule


PublicClassForm1ClassForm1
InheritsSystem.Windows.Forms.Form

WindowsFormDesignergeneratedcode#Region"WindowsFormDesignergeneratedcode"

#EndRegion


<[Serializable]()>PublicClassArtClassArt
PublicTitleAsString
PublicDesAsString
PublicValueAsInteger
PublicPriceAsDouble
PublicPictureAsString
EndClass


PrivateSubButton1_Click_1()SubButton1_Click_1(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
DimmyArtAsNewObject
DimhashtableAsNewCollections.Hashtable
DimkeyAsString

Try
myArt
=NewArt
WithmyArt
.Title
="Title"
.Des
="Desc"
.Value
=123
.Price
=321.05
EndWith
key
=myArt.Title&myArt.Des&CStr(myArt.Value)&CStr(myArt.Price)
hashtable.Add(key,myArt)
ArtList.Add(myArt)

CatchexAsException'Thisistheline94’
MsgBox(ex.Message&vbCrLf&ex.StackTrace)
EndTry
EndSub

EndClass

Aform
iscreatedonwhichabuttoncontrolisplaced.WhentheButton1_Clickisfired,amessageboxispopup:



What
istheproblemandhowtofixit?

Answer:


Question
4

InthefollowingVBprogram,pleasestatesanypotentialproblem(s)andhowtocorrect.

PrivateSubbtnCalc_Click()SubbtnCalc_Click()
DimresultAsInteger
Try
Me.Cursor=Windows.Forms.Cursors.WaitCursor
result
=Convert.ToInt32(txtInput1.Text)/Convert.ToInt32(txtInput2.Text)
txtResult.Text
=result
Me.Cursor=Windows.Forms.Cursors.Default
CatchexAsException
MsgBox(ex.StackTrace)
CatchexAsArgumentNullException
MsgBox("InputTestboxcannotbenull.")
CatchexAsOverflowException
MsgBox("InputTestbox2cannotbezero!")
CatchexAsFormatException
MsgBox("InputTestboxshouldbenumericformat!")
EndTry
EndSub


Answer:


Question
5

GetRecordset()
isaVBFunctionthat()functionthatreturnsaADODB.Recordsetobject:

Ref_IDQtyPrice
Row
000123100060.50
Row
100123200060.00
Row
200123350059.50
Row
300124300060.50
Row
400125200059.50
Row
500125100058.00

(Thisrecordset
issortedbyRef_ID)

Thefollowingprogram

DimrstasADODB.Recordset
Rst
=GetRecordset
DoWhileNotrst.EOF
Console.writeline(rst.Fields(
"Ref_ID")&vbcrlf&rst.Fields("Qty")&vbcrlf&rst.Fields("Price"))
rst.MoveNext()
Loop

Cangeneratethefollowingoutput:

Output:

00123100060.50
00123200060.00
00123350059.50
00124300060.50
00125200059.50
00125100058.00

Pleasesuggesthow
tomodifytheaboveprogramtogeneratethefollowingoutput:

Output:
00123
100060.50
200060.00
350059.50
---------
650060.00
00124
300060.50
---------
300060.50
00125
200059.50
100058.00
------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值