百度技术研发笔试题目

百度技术研发笔试题目

ID:30894606

大小:135.28 KB

页数:23页

时间:2019-01-04

百度技术研发笔试题目_第1页
百度技术研发笔试题目_第2页
百度技术研发笔试题目_第3页
百度技术研发笔试题目_第4页
百度技术研发笔试题目_第5页
资源描述:

《百度技术研发笔试题目》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、百度技术研发笔试题目BaiduR&Dwrittenquestions/*Baiduinterviewquestions*a27cmfinewood,inthirdcm,7cm,11cm,17cm,23cmandfivepositionseachhaveanant・*woodisveryfine,notbyanantatthesametime・Atthebeginning,theantsheadtowardstheleftorrightisarbitrary,theywillonlygoaheadorturnaround,

2、*butnotbackward.Whenanytwoantsmeet,twoantsturnbackandwalkintheoppositedirection.Assumethattheantscanwalkdistaneeofonecentimeterpersecond・*writeaprogramforallantsleavetheminimumtimeandthemaximumtimeofthepole・***analysis:inthetitleofantsmaymeetintheintegerpoints,ca

3、nnotmeetatotherpoints,suchas3.5cm,thatis,eachantcanletgoasecond,then*toseeiftherearemet・I*programsuchideasisthattheinitializatdonof5ants,leteachantgo1,andseewhethertherearemet,ifthereisacorrespondingtreatmentwheneveryant・WhenIwasoutofthewoods:*,recordsthecurrentt

4、ime・Sowecangetthecurrentstatus,howlongcanbeoutofthewoods,andthentraverseallthestatecanbeobtainedbyHu*・*/Packagebaidu;Publicclass{Ant**stepsaidtakeantseveryunitlengthoftime*/PrivatefinalstaticintStep二1;**positionsaidtheinitialpositionoftheant*/Privateintposition;*

5、directionsaidthedirectionofants,if1to27cmdirection,if1,saidtothe0direction・*/Privateintdirection二1:**thisfunctiononce,saidtheantforwardaunitoftime,ifyouhavewalkeddownthewoodenexceptionisraised*/Publicvoid(walk){If((isOut)){ThrownewRuntimeException("theantisout");

6、}Position二position+this.direction*step;};Checkwhethertheant*hasbeenoutofthewoods,ifoutofthereturntrue**/PublicBoolean(isOut){Returnposition0

7、

8、〈position〉二27;/**Theant*checkwhetherhavemetanotherant*@paramantIfyoureturntrue*@return*/PublicBooleanisEncounter(Antant){

9、Returnant.position二二this.position;*thedirectionchangeofants*/Publicvoid(changeDistation){Direction二一1*direction;/***constructor,thedirectionoftheinitialsetofants,andtheinitialposition*@paramposition*@paramdirection*/PublicAnt(intposition,intdirection){This・positi

10、on二position;If(direction!二1){This.direction二T;//setthedirectionoftheinitialposition,suchas0,willbesetto1.soyoucaneasily.{else}This.direction二1;////////////////

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。