沂濛的小站

  • 首页
  • Blog
    • 足球,终生为蓝
    • 随笔,记录点滴
    • 杂谈,感悟人生
    • 诗馀,品味生活
    • 围棋,坐隐棋枰
    • 影评,读书笔记
    • 杂烩,林林总总
    • 编程,码工细语
  • CBD围棋&双象俱乐部
沂濛的小站
  1. 首页
  2. 编程,码工细语
  3. 正文

一篇PHP软件工程师笔试答卷

18 2 月, 2012 587点热度 0人点赞 0条评论

自己面试过程中所做的一次笔试,感觉挺简单的,属于入门level,只是试试手,公司名称就不透露了。因为没有签署保密协议,所以把部分试题和我做的答案以图片形式附在下面,以后偶尔时复习看看。试题如下:

1. 现有DIV1, DIV2和DIV3,请用html+CSS实现以下布局(中间为DIV名字,不用实现)

答案:
2. 使用以下任何一种编程语言,编写一个快速排序函数quicksort。实现输入数字的排序功能。(PHP, JavaScript, Java, Object-c, C, ASP)

答案:

PHP版本:

<?php
function quicksort(&$arr,$left,$right){
$index=partition($arr,$left,$right);
if($left<$index-1) quicksort($arr,$left,$index-1);
if($index<$right) quicksort($arr,$index,$right);
}function partition(&$arr,$left,$right){
$pivot=$arr[($left+$right)/2];
while($left<=$right){
while($pivot>$arr[$left]) $left++;
while($pivot<$arr[$right]) $right--;
if($left<=$right){
$s=$arr[$left];
$arr[$left]=$arr[$right];
$arr[$right]=$s;
$left++;
$right--;
}
}
return $left;
}
?>

Java版本:

public static void quicksort(int[] array,int left,int right){
int index=partition(array,left,right);
if(left<index-1){
quicksort(array,left,index-1);
}
if(index<right){
quicksort(array,index,right);
}
}private static int partition(int[] array,int left,int right){
int pivot=array[(left+right)/2];
while(left<=right){
while(array[left]<pivot) left++;
while(array[right]>pivot) right--;
if(left<=right){
int i=array[left];
array[left]=array[right];
array[right]=i;
left++;
right--;
}
}
return left;
}

 

3. 有一张文章评论表comment如下:

 

以上是一个应用的comment表格的一部分,请使用SQL语句找出在本站发表的所有的评论数最多的前10位用户及其评论数,并按评论数从高到低排序(默认使用MySQL数据库)。

答案:

select sum(count),user_id

from comment

group by Article_id

order by T desc

limt 10;

4. 编写正则表达式取出以下字符串的链接地址(即http...部分),选择你熟悉的语言完成即可,C,PHP,JS,Java等任意语言。

<a href="http://www.facebook.com/notes/snappy-tomato-pizza/index.php" target="_blank">Snappy Tomato Pizza</a>

答案:

&lt;?php

    $string="例子";

    $a="/http.+\.php/";

    if(prep_match($a,$string,$b))

    echo $b[0];

?&gt;

5. 有文章表article(id, title, post_date),评论表comments(id, article_id, content, post_date)。 请写出SQL语句找出当天最新的10条评论(每篇文章只能找出一条评论)。

答案:

select *
from comments,(select article_id as id, max(tiemstamp(post_date)) as time
                               from comments
                               where to_days(post_sate)=to_days(now())
                               group by article_id) as T
where comments.article_id=T.id and timestamp(comments.post_date)=T.time
order by T.time
limit 10;

6. 找出执行时间最长的SQL语句。 解释MySQL多字段索引的执行情况。

答案:这道题的问题比较模糊,现在也没能理解是什么意思,知道的朋友帮我解答一下。

7. 分别列举3个例子,什么样的编程行为/函数,有助优化PHP/JSP/.NET的数据库读写速度,什么样的操作设置不利于数据库快速响应? 

答案:

  1. 尽量减少使用数据库链接的次数,IO访问花费时间比较长。
  2. 对数据的处理尽量写在SQL中,不要写在php中,数据库效率高。
  3. 使用面向对象的函数调用数据库比直接使用数据库函数好一些。
标签: 暂无
最后更新:2 12 月, 2022

沂濛

爱好广泛的纽约小文艺

打赏 点赞
下一篇 >

文章评论

您需要 登录 之后才可以评论
归档
  • 2025 年 3 月
  • 2025 年 1 月
  • 2024 年 12 月
  • 2024 年 11 月
  • 2024 年 10 月
  • 2024 年 8 月
  • 2024 年 7 月
  • 2024 年 6 月
  • 2024 年 4 月
  • 2024 年 3 月
  • 2024 年 2 月
  • 2024 年 1 月
  • 2023 年 12 月
  • 2023 年 11 月
  • 2023 年 9 月
  • 2023 年 8 月
  • 2023 年 5 月
  • 2023 年 4 月
  • 2023 年 3 月
  • 2023 年 1 月
  • 2022 年 12 月
  • 2022 年 11 月
  • 2022 年 9 月
  • 2022 年 8 月
  • 2022 年 6 月
  • 2022 年 5 月
  • 2022 年 3 月
  • 2021 年 12 月
  • 2021 年 10 月
  • 2021 年 9 月
  • 2021 年 8 月
  • 2021 年 7 月
  • 2021 年 6 月
  • 2021 年 5 月
  • 2021 年 3 月
  • 2021 年 2 月
  • 2021 年 1 月
  • 2020 年 12 月
  • 2020 年 11 月
  • 2020 年 8 月
  • 2020 年 7 月
  • 2019 年 12 月
  • 2018 年 12 月
  • 2018 年 9 月
  • 2018 年 8 月
  • 2018 年 7 月
  • 2018 年 5 月
  • 2018 年 3 月
  • 2018 年 1 月
  • 2017 年 12 月
  • 2017 年 7 月
  • 2017 年 5 月
  • 2017 年 2 月
  • 2016 年 11 月
  • 2016 年 10 月
  • 2016 年 9 月
  • 2016 年 5 月
  • 2016 年 4 月
  • 2016 年 3 月
  • 2016 年 2 月
  • 2016 年 1 月
  • 2015 年 12 月
  • 2015 年 10 月
  • 2015 年 9 月
  • 2015 年 8 月
  • 2015 年 7 月
  • 2015 年 6 月
  • 2014 年 12 月
  • 2014 年 11 月
  • 2014 年 10 月
  • 2014 年 9 月
  • 2014 年 5 月
  • 2014 年 4 月
  • 2013 年 1 月
  • 2012 年 11 月
  • 2012 年 9 月
  • 2012 年 7 月
  • 2012 年 5 月
  • 2012 年 4 月
  • 2012 年 3 月
  • 2012 年 2 月
  • 2011 年 11 月
  • 2011 年 8 月
  • 2011 年 3 月
  • 2011 年 2 月
  • 2011 年 1 月
  • 2010 年 12 月
  • 2010 年 10 月
  • 2010 年 9 月
  • 2010 年 8 月
  • 2010 年 7 月
  • 2010 年 6 月
  • 2010 年 3 月
  • 2010 年 1 月
  • 2009 年 12 月
  • 2009 年 9 月
  • 2009 年 8 月
  • 2009 年 7 月
  • 2009 年 6 月
  • 2009 年 5 月
  • 2009 年 4 月
  • 2009 年 2 月
  • 2009 年 1 月
  • 2008 年 11 月
  • 2008 年 10 月
  • 2007 年 7 月
  • 2007 年 6 月
  • 2007 年 5 月
  • 2007 年 4 月
  • 2007 年 3 月
  • 2007 年 2 月
  • 2007 年 1 月
  • 2006 年 12 月
  • 2006 年 11 月
  • 2006 年 10 月
分类
  • 围棋,坐隐棋枰
  • 影评,读书笔记
  • 杂烩,林林总总
  • 杂谈,感悟人生
  • 编程,码工细语
  • 诗馀,品味生活
  • 足球,终生为蓝
  • 随笔,记录点滴

COPYRIGHT © 2025 沂濛 版权所有

All Designed By Yimeng Lu

京ICP备2022015169号-1