⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 一份软件工程师的面试试题.htm

📁 行业经典面试题
💻 HTM
字号:

<HTML>
<HEAD>
<title>一份软件工程师的面试试题</title>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<style type="text/css">
A{TEXT-DECORATION: none}
A:link {COLOR: #666666; FONT-FAMILY: 宋体; TEXT-DECORATION: none}
A:visited {COLOR: #666666; FONT-FAMILY: 宋体; TEXT-DECORATION: none}
A:active {FONT-FAMILY: 宋体; TEXT-DECORATION: none}
A:hover {BORDER-BOTTOM: 1px dotted; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-WIDTH: 1px; COLOR: #ff6600; TEXT-DECORATION: none}
BODY {
FONT-SIZE: 12px;
COLOR: #666666;
FONT-FAMILY:  宋体;
background-color: #ffffff; 
background-image: url(img/show.gif);
SCROLLBAR-FACE-COLOR: #e8e7e7; 
SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; 
SCROLLBAR-SHADOW-COLOR: #ffffff; 
SCROLLBAR-3DLIGHT-COLOR: #cccccc; 
SCROLLBAR-ARROW-COLOR: #ff6600; 
SCROLLBAR-TRACK-COLOR: #EFEFEF; 
SCROLLBAR-DARKSHADOW-COLOR: #b2b2b2; 
SCROLLBAR-BASE-COLOR: #000000
}
TABLE {BORDER-COLLAPSE: collapse; FONT-FAMILY: 宋体; FONT-SIZE: 9pt}
.button{height:18px;width:62px;background:#f6f6f9 url(img/ButtonBg.gif); border:solid 1px #5589AA;color: #000000 ;FONT-SIZE: 9pt}
.lanyu{border:solid 1px #5589AA;color: #000000 ; font-size: 12px;}
.font {  filter: DropShadow(Color=#cccccc, OffX=2, OffY=1, Positive=2); text-decoration: none; font-size: 9pt}
</style>
<script language="JavaScript">
function findobj(n, d) {
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0 && parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all) {
x=d.all[n];
}
for(i=0;!x && i<d.forms.length;i++) {
x=d.forms[i][n];
}
for(i=0;!x && d.layers&&i>d.layers.length;i++) {
x=MM_findObj(n,d.layers[i].document);
}
return x;
}
function copycode(obj) {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
</script>
</head>
<BODY leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<TABLE bgcolor="#ffffff" align=center border=1 cellPadding=0 cellSpacing=0 width=95% borderColor="#666666" frame=vsides rules=none>

<TR>
<TD width="98%">
<table border="0"><tr><td height="5"></td></tr></table>

<table width="96%" border="0" cellspacing="1" cellpadding="6" align="center" bgcolor="#BDC0C8">
        <tr> 
          <td align="center" bgcolor="#FFFFFF"><font color=ff6600><b>一份软件工程师的面试试题</b></font></td>
        </tr>
      </table>
<table border="0"><tr><td height="5"></td></tr></table>

<table width="96%" border="0" cellspacing="1" cellpadding="6" align="center" bgcolor="#BDC0C8">
        <tr> 
          <td align="center" bgcolor="#FFFFFF">
<table width="98%">
        <tr> 
          <td id=qq_595911 style="word-break:break-all;line-height:150%"> 
            <br><font color=000000>
            1、现有1000个苹果,10个盒子,问各个盒子内应该分别放入多少个苹果,才能使得用户要买任意1至1000之间的一个苹果数,都可以给他(卖的时候是整个盒子卖,不能拆盒子的包装)。<BR><BR>2、请仔细阅读下面的资料:<BR><BR>1)材料一:CArray<BR>template&lt; class TYPE, class ARG_TYPE &gt; class CArray : public CObject<BR>Parameters:<BR>TYPE<BR>Template parameter specifying the type of objects stored in the array. <BR>TYPE is a parameter that is returned by CArray.<BR>ARG_TYPE<BR>Template parameter specifying the argument type used to access objects stored in the array. <BR>Often a reference to TYPE. ARG_TYPE is a parameter that is passed to CArray.<BR>Remarks:<BR>The CArray class supports arrays that are are similar to C arrays, but can dynamically shrink and grow as necessary. <BR>Array indexes always start at position 0. You can decide whether to fix the upper bound or allow the array to expand when you add elements past the current bound. Memory is allocated contiguously to the upper bound, even if some elements are null.<BR><BR>int CArray::Add (ARG_TYPE newElement);<BR><BR>Return Value:<BR>The index of the added element.<BR>Parameters:<BR>ARG_TYPE<BR>Template parameter specifying the type of arguments referencing elements in this array.<BR>newElement<BR>The element to be added to this array.<BR><BR>TYPE& CArray::operator [] (int nIndex);<BR>Parameters:<BR>TYPE<BR>Template parameter specifying the type of elements in this array.<BR>nIndex<BR>Index of the element to be accessed.<BR>Remarks:<BR>Returns the array reference of element at the specified index.<BR><BR>2)材料二:CList<BR>template&lt;class TYPE, class ARG_TYPE&gt;class CList : public CObject<BR>Parameters:<BR>TYPE<BR>Type of object stored in the list.<BR>ARG_TYPE<BR>Type used to reference objects stored in the list. Can be a reference.<BR>Remarks:<BR>The CList class supports ordered lists of nonunique objects accessible sequentially or by value. <BR>CList lists behave like doubly-linked lists. <BR><BR>void CList::AddTail(ARG_TYPE newElement);<BR>Parameters:<BR>ARG_TYPE<BR>Template parameter specifying the type of the list element (can be a reference).<BR>newElement<BR>The element to be added to this list.<BR>Remarks:<BR>Adds a new element or list of elements to the tail of this list. The list can be empty before the operation.<BR><BR>3)材料三: realloc<BR>realloc<BR>Reallocate memory blocks.<BR>void *realloc(void *memblock, size_t size);<BR>Return Value:<BR>The return value points to a storage space that is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than void, use a type cast on the return value.<BR>Remarks:<BR>The size argument gives the new size of the block, in bytes. The contents of the block are unchanged up to the shorter of the new and old sizes, although the new block can be in a different location. Because the new block can be in a new memory location, the pointer returned by realloc is not guaranteed to be the pointer passed through the memblock argument.<BR><BR>4)请指出下面这段代码可能会出现的问题<BR>CList&lt;VARIANT*, VARIANT*&gt; g_ValueList;<BR>CArray&lt;VARIANT, const VARIANT&&gt; g_ValuePool;<BR>void AddNewValue (const VARIANT& newValue)<BR>{<BR>g_ValueList.AddTail(&g_ValuePool[g_ValuePool.Add(newValue)]);<BR>}<BR><BR>3、有一无符号整型数组,大小为10, 初始的数值随机,但在[0, 99]之间。请用C语言写一个过滤程序,令数组内的数据互不相等。<BR>说明:<BR>1.若数组内有相等的数据,可令某一数值加1或减1作出偏移,直至不等为止。<BR>2.数组内的数据只能在[0, 99]之间。<BR>3.保持数组内的数据位置不变,即对应下标不变。<BR><BR>4、 按要求编写以下函数。<BR>功能:将给定缓冲区中的#字符移到字符串尾部<BR>函数名称:ChangeToTail<BR>入口参数:pSZ指向缓冲区的指针, nSize缓冲区长度<BR>出口:pSZ所指缓冲区中的#字符被移到缓冲区尾部<BR>返回值:在出口缓冲区中第一个#的位置,若缓冲区中无#字符则返回-1<BR>说明:如传入#W#W#W#WW#, 10 则传出时应转换为WWWWW#####并且返回值为5<BR>int ChangeToTail(BYTE* pSZ, UINT nSize)<BR>{<BR>// Todo:请在此加入您的代码<BR>}<BR><BR>5、在金山,有一个非常经典有趣的游戏,称为杀人游戏。此游戏角色有:好人(m人)、坏人(n人)、村长(1人)、裁判(1人)。角色采用一定方式(如:抓阄)分配。村长、裁判两个角色是公开的,而好人、坏人两个角色则只要裁判和本人心知肚明。其玩法如下:<BR>游戏开始了,裁判说:“天黑了”,这是所有其他角色都低头闭上眼睛(不准作弊!)。然后裁判说:“坏人开始活动”,此时坏人抬起头,并相互商议,杀死一个好人。然后裁判说:“天亮了”,此时所有人抬头,被杀死的那个好人宣布出局。剩下的人在村长的主持下,开始判断杀人凶手。每个人可以根据各人的表情反应,判断并提议杀死自己心目中的坏人。不过最终的裁决权属于村长,综合大家的意见杀死一人。此时裁判宣布此人出局。游戏进入下一轮,由天黑到天亮,再有2人出局,如此反复,直到最后好人先被全部杀死,则游戏结束,“邪恶”的一方战胜了“正义”的一方;而另一个结局则是在大家以及村长的英明决断下,坏人被全部杀死,则“正义”的一方战胜了“邪恶”的一方。<BR>现在,我们的问题是,请写出你的思路,并编写一个C/C++语言程序,求出:在坏人有两个(n = 2)的情况下,需要多少个好人(m = ?),才能够使这个游戏比较公平,也就是说,从概率上说,“正义”的一方与“邪恶”的一方胜利的几率最接近于50%。<BR>(此题与下面一题选做一道)<BR>6、在以上的杀人游戏中,还有一个玩法,就是取消村长这个角色,“天亮”后剩余的人每个人投票列出自己心目中最怀疑的2个人,以此决定让谁出局。试问,在此玩法下,上面的问题又何解?<BR>7.C++程序设计<BR>1).写出以下程序的运行结果:<BR>#include &lt;iostream&gt;<BR>class Base<BR>{<BR>public:<BR>Base()<BR>{<BR>cout &lt;&lt; "Base()" &lt;&lt; endl;<BR>}<BR>Base(const Base &theBase)<BR>{<BR>cout &lt;&lt; "Base(const Base &theBase)" &lt;&lt; endl;<BR>}<BR>~Base()<BR>{<BR>cout &lt;&lt; "~Base()" &lt;&lt; endl;<BR>}<BR>void Open()<BR>{<BR>OnOpen();<BR>}<BR>private:<BR>virtual void OnOpen() = 0;<BR>};<BR><BR>class Derived : public Base<BR>{<BR>public:<BR>Derived()<BR>{<BR>cout &lt;&lt; "Derived()" &lt;&lt; endl;<BR>}<BR>Derived(const Derived &theDerived)<BR>{<BR>cout &lt;&lt; "Derived(const Derived &theDerived)" &lt;&lt; endl;<BR>}<BR>~Derived()<BR>{<BR>cout &lt;&lt; "~Derived()" &lt;&lt; endl;<BR>}<BR>private:<BR>virtual void OnOpen()<BR>{<BR>//这里可能抛出异常<BR>}<BR>};<BR><BR>Base *CreateInstance()<BR>{<BR>return new Derived();<BR>}<BR><BR>int main()<BR>{<BR>Base *pBase = ::CreateInstance();<BR>if (pBase)<BR>{<BR>pBase-&gt;Open();<BR>delete pBase;<BR>}<BR>return 0;<BR>}<BR><BR>2).在1)中,类Base和类Derived的实现有没有问题?如果有,如何修改?<BR><BR>3).说明1)中类Base的Open函数和OnOpen函数的设计目的和意义。<BR><BR>4).使用STL技术修改main()函数中的代码,使之成为异常安全的。<BR><BR><BR><BR><BR><BR>后记<BR>  这是在北京一家培训公司的论坛上看见的,不过没有一个人来回答,所以贴到这来让大家看看,最后一题中,有一些特别技巧性的东西(如3),我见过一篇文章介绍了一些,后不知为何没有保存,真可惜。</font> <br>
            <br>
            --------------------------------------------------------------------------------<br>
            &nbsp;<img src=img/none.gif border=0><img src=img/i8.gif border='0'>&nbsp;<b>相关文章</b><br>
            没有相关文章
           </td>
        </tr>
      </table></td>
        </tr>
      </table>
      
<table border="0"><tr><td height="5"></td></tr></table>

      <table width="96%" border="0" cellspacing="1" cellpadding="6" align="center" bgcolor="#BDC0C8">
        <tr> 
<td bgcolor="ffffff"><font color=red>分类:
            
            <a href="art.asp?cat_id=11" target="_blank"><font color="#009900">综合类</font></a> 
            日期:2006-7-30  查看:32</font></td>       
<td align="center" bgcolor="#FFFFFF"><input type="button"  value="复制"  onClick="copycode(findobj('qq_595911'));" class="button">&nbsp;<input type="button"  value="打印"  onClick="javascript:window.print()" class="button">&nbsp;<input type="button"  value="返回"  onClick="window.open('http://www.pghome.net')" class="button">&nbsp;<input type="button" name="close2" value="关闭"  onClick="window.close();return false;" class="button"></td></tr>
      </table>

<table border="0"><tr><td height="5"></td></tr></table>

<table border="0"><tr><td height="5"></td></tr></table>

</td>
        </tr>
<TR><td height="1" width="100%" bgcolor="#666666"></td></tr>
      </table>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -