喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

[北京]代朋友公司招聘PHP高级程序员多名

上一主题 下一主题
 17  1/2  1  2  > 
     
标题: [问题] 再发几个笔试题  
 
轻舞飞扬 (七烨)
高级会员
Rank: 4



UID 94218
精华 0
积分 760
帖子 1425
金钱 760 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2007-6-20
来自 魔族(墨月)
状态 离线
再发几个笔试题

// ----------- Test PHP questions ---------------------

// Write a function that determines if a string starts with an upper-case letter A-Z
//写一个函数,判断一个字符串首字母是否以大写字母A-Z开头。
function startsWithUpper( $str ) {
// --- Your code here ---
}

// Write a function that determines the area of a circle given the radius
//写一个函数,判断一个给定半径的圆的面积。
function areaOfCircle( $radius ) {
// --- Your code here ---
}

// Add up all the values in an array of numbers.
// 给一个数值型数组添加值(成员)
function addValuesInArray( $array ) {
// --- Your code here ---
}

// Write a recursive function to multiply all the values in an array of numbers.
// 写一个递归函数,用来遍历一个数值型数组中的所有值(成员)
function recursiveArrayMultiply( $array ) {
// --- Your code here ---
}

// Are there any bugs in the following function, and if so, what are they?
//在下边的函数中是否有小bug,如果有,是什么bug?
/**
* Determines whether the string contains a certain character.
* @param char $char A single character
* @param string $string A string of characters
* @return boolean True if the string contains the specified character.
*/
function stringContainsChar( $char, & $string ) {
   for( $i=1; $i<=strlen( $string ); $i++) {
       if( $string[$i] = $char ) return true;
   }
   return 'false';
}

// You are given this sample code:
//给出一些代码(例子)
$a = new A();
$a->addNumber( 3 );
$a->addNumber( 5 );
print $a->getNumber() . "\n"; // prints "8\n";
// From the above code, write an implementation of class A.
// 从上边的代码开始,写一个完整的类A.

// Create a dynamic web page that displays a list of countries in alphabetical order,
// and which allows countries to be removed from the list, and allows new countries to be
// added to the list. The list of countries should be stored in a text file,
// called countries.txt , in the same directory as your PHP script, and each line of
// the file should correspond to one country. An example countries.txt file is:
United States
Australia
Serbia
Canada
China

// Bonus question: Attempt the above (displaying the list of countries, and allowing countries
// to be added or removed) using MediaWiki 1.9.3, and storing the list of countries in a wiki page.
// The form for displaying, adding, and removing countries should be a Special page.
// MediaWiki 1.9.3 can be downloaded from http://download.wikimedia.org/me ... iawiki-1.9.3.tar.gz
// Some documentation on writing a special page can be accessed from here:
// http://www.mediawiki.org/wiki/Writing_a_new_special_page
// Credit WILL be given for partial or incomplete answers, so even if you have a partial
// or unfinished answer, please submit that.




我轻轻地舞着,在拥挤的人群之中!
你投射过来异样的眼神.
诧异也好,欣赏也罢.
并不曾使我的舞步凌乱.
因为令我飞扬的,不是你注视的目光.
而是我年轻的心!
2007-9-13 03:22 PM#1
查看资料  发短消息  QQ  顶部
 
没看见 (帅哥杨)
高级会员
Rank: 4
被遗忘的漏洞


UID 67293
精华 0
积分 824
帖子 850
金钱 824 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2005-12-19
状态 离线
[推荐阅读] 发现我真的挺穷...
要么看不懂,要么不会



某年某月某日某时某分某秒某人在路边摔了一跤
没意思?请去没意思吧http://www.meiysi.com
2007-9-13 04:17 PM#2
查看资料  Blog  发短消息  QQ  顶部
 
elandcn
新手上路
Rank: 1



UID 97044
精华 0
积分 10
帖子 40
金钱 10 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-8-16
状态 离线
[推荐阅读] grldr 提示无效,E盘需要分区吗
真的蛮无聊的 说真的
2007-9-13 04:40 PM#3
查看资料  发短消息  顶部
 
轻舞飞扬 (七烨)
高级会员
Rank: 4



UID 94218
精华 0
积分 760
帖子 1425
金钱 760 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2007-6-20
来自 魔族(墨月)
状态 离线
[推荐阅读] 关于字符串和数组的区别
真的是面试题啊!
下面是我写的,饿得我迷迷糊糊的,都快没有思想了,写玩了人家没看
//写一个函数,判断一个字符串首字母是否以大写字母A-Z开头。
function startsWithUpper( $str )
{
        $var="^[A-Z]";
        if (ereg($var,$str))
                return ture;
        else
                return false;

}


//写一个函数,判断一个给定半径的圆的面积。
function areaOfCircle( $radius )
{       
        $Pi=3.14;
        $area=$pi*$radius*$radius;
        return $area;
               
}

// 写一个递归函数,用来遍历一个数值型数组中的所有值(成员)
function recursiveArrayMultiply( $array )

{
        if ($array==0)
                return 0;
        else
                return recursiveArrayMultiply($array-1);


}
//在下边的函数中是否有小bug,如果有,是什么bug?
/**
* Determines whether the string contains a certain character.
* @param char $char A single character
* @param string $string A string of characters
* @return boolean True if the string contains the specified character.
*/
function stringContainsChar( $char, & $string ) {
   for( $i=1; $i<=strlen( $string ); $i++) {
       if( $string[$i] = $char ) return true;
   }
   return 'false';
}

答:函数 stringContainsChar中有小bug,参数不对

calss A
{
        var number1;
        var number2;
       
        function addNumber($number)
        {
                $this->number1=$number;
        }
        function _dissect()
        {
        }
        function getNumber($number)
        {
                echo $this->number1+$this->number1;
        }
}




我轻轻地舞着,在拥挤的人群之中!
你投射过来异样的眼神.
诧异也好,欣赏也罢.
并不曾使我的舞步凌乱.
因为令我飞扬的,不是你注视的目光.
而是我年轻的心!
2007-9-13 06:06 PM#4
查看资料  发短消息  QQ  顶部
 
jtql420 (披着羊皮的狼)
金牌会员
Rank: 6Rank: 6
披着羊皮的狼


UID 70611
精华 0
积分 1965
帖子 444
金钱 1965 喜悦币
威望 0
人脉 0
阅读权限 70
注册 2006-3-29
来自 深圳
状态 离线
[推荐阅读] 再会无缘的情人


QUOTE:
calss A
{
        var number1;
        var number2;
      
        function addNumber($number)
        {
                $this->number1=$number;
        }
        function _dissect()
        {
        }
        function getNumber($number)
        {
                echo $this->number1+$this->number1;
        }
}
你就没有理解题目的意思,

calss A
{
        var number;
      
        function addNumber($number)
        {
                $this->number += $number;
        }

        function getNumber()
        {
                return $this->number;
        }
}




披着羊皮的狼 http://jtql420.cn
2007-9-14 09:04 AM#5
查看资料  访问主页  发短消息  QQ  顶部
 
bnini
等待验证会员

中级会员



UID 12628
精华 0
积分 416
帖子 448
金钱 416 喜悦币
威望 0
人脉 0
阅读权限 0
注册 2002-2-2
来自 上海
状态 离线
[推荐阅读] 为什么我的js没有作用
// Are there any bugs in the following function, and if so, what are they?
//在下边的函数中是否有小bug,如果有,是什么bug?
/**
* Determines whether the string contains a certain character.
* @param char $char A single character
* @param string $string A string of characters
* @return boolean True if the string contains the specified character.
*/
function stringContainsChar( $char, & $string ) {
   for( $i=1; $i<=strlen( $string ); $i++) {
       if( $string[$i] = $char ) return true;
   }
   return 'false';
}

5个错误

<?php
function stringContainsChar$char, & $string ) {
   for( 
$i=0$len=strlen$string ); $i<$len;$i++) {
       if( 
$string[$i] == $char ) return true;
   }
   return 
false;
}
?>
2007-9-14 10:39 AM#6
查看资料  发短消息  顶部
 
漠北怪叟
金牌会员
Rank: 6Rank: 6



UID 70640
精华 0
积分 2353
帖子 368
金钱 2353 喜悦币
威望 0
人脉 0
阅读权限 70
注册 2006-3-29
状态 离线
[推荐阅读] switch 和for循环的效率问题
// Write a recursive function to multiply all the values in an array of numbers.
// 写一个递归函数,用来遍历一个数值型数组中的所有值(成员)
function recursiveArrayMultiply( $array ) {
        if (is_array($array)){
                foreach($array as $k){
                  recursiveArrayMultiply($k);
                }
        }
}

// Are there any bugs in the following function, and if so, what are they?
//在下边的函数中是否有小bug,如果有,是什么bug?
/**
* Determines whether the string contains a certain character.
* @param char $char A single character
* @param string $string A string of characters
* @return boolean True if the string contains the specified character.
*/
function stringContainsChar( $char, & $string ) {
   for( $i=1; $i<=strlen( $string ); $i++) {
       if( $string[$i] = $char ) return true;
   }
   return 'false';
}
答1  $string[$i] ->   strlen( $string ) 前者几时变成数组了? 后
2  $string[$i] = $char -> 应该是==. 现在写在赋值了.
3 return 'false';  -> 应该是return false

// You are given this sample code:
//给出一些代码(例子)
$a = new A();
$a->addNumber( 3 );
$a->addNumber( 5 );
print $a->getNumber() . "\n"; // prints "8\n";
// From the above code, write an implementation of class A.
// 从上边的代码开始,写一个完整的类A.

class A{
        function A(){
                $this->tmp_number=0;
        }
        function addNumber($number){
                $this->tmp_number+=$number;
        }
        function getNumber(){
                return $this->tmp_number;
        }
}

// Create a dynamic web page that displays a list of countries in alphabetical order,
// and which allows countries to be removed from the list, and allows new countries to be
// added to the list. The list of countries should be stored in a text file,
// called countries.txt , in the same directory as your PHP script, and each line of
// the file should correspond to one country. An example countries.txt file is:
United States
Australia
Serbia
Canada
China

$fp=fopen($fn="countries.txt","r");
$txt_FileContent=fread($fp,filesize($fn));
fclose($fp)
$ary_countries=explode("\r\n",$txt_FileContent);
rsoft($ary_countries);
foreach ($ary_countries as $k){
  echo "<br>{$k}";
}

英文不好.后面的看不懂...




我的博客:http://hjc73.space.mywallop.cn
2007-9-14 10:41 AM#7
查看资料  Blog  发短消息  顶部
 
圣斗士的信仰
注册会员
Rank: 2



UID 84775
精华 0
积分 74
帖子 76
金钱 74 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2006-12-13
状态 离线
[推荐阅读] 紧急求职phper
回复 #6 bnini 的帖子

--------------------------------------------------------------------------------
// Are there any bugs in the following function, and if so, what are they?
//在下边的函数中是否有小bug,如果有,是什么bug?
/**
* Determines whether the string contains a certain character.
* @param char $char A single character
* @param string $string A string of characters
* @return boolean True if the string contains the specified character.
*/
function stringContainsChar( $char, & $string ) {
   for( $i=1; $i<=strlen( $string ); $i++) {
       if( $string[$i] = $char ) return true;
   }
   return 'false';
}

5个错误


CODE:[Copy to clipboard]<?php
function stringContainsChar( $char, & $string ) {
   for( $i=0; $len=strlen( $string ); $i<$len;$i++) {//显然,你这里面有错。($i=0,$len=strlen($string);$i<$len;$i++),其实原题的错,我就看到三个.
       if( $string[$i] == $char ) return true;//==之1
   }
   return false;//多用引号之2,第三处,就是应该从0开始查找字串。这是主要的BUG。
}
?>
2007-9-14 10:48 AM#8
查看资料  发短消息  顶部
 
xjxaixxy (xjxaixxy)
新手上路
Rank: 1
初级会员



UID 31002
精华 0
积分 15
帖子 19
金钱 15 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2004-9-9
状态 离线
[推荐阅读] 请教一个数组排序问题
试一下递归的,现写的,没测试过
function recursiveArrayMultiply( $array )
{
        foreach($array as $a) {
                if(is_array($a)) {
                        recursiveArrayMultiply($a);
                } else {
                        echo $a;
                }
        }
}

[ 本帖最后由 xjxaixxy 于 2007-9-14 11:06 AM 编辑 ]
2007-9-14 11:05 AM#9
查看资料  发短消息  顶部
 
村长夫人
高级会员
Rank: 4


UID 94673
精华 0
积分 501
帖子 973
金钱 501 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2007-6-29
状态 离线
[推荐阅读] base64 bug? 急呀
第一道题
function startsWithUpper( $str ) {
return strtoupper($str[0]) == $str[0];
}




又该换马甲了.....
2007-9-14 12:06 PM#10
查看资料  发短消息  顶部
 17  1/2  1  2  > 
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 4.114276 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP