现在的位置: 首页 > 综合 > 正文

“授人以鱼,不如授人以渔”,观BSS贴子有感;

2013年10月21日 ⁄ 综合 ⁄ 共 2369字 ⁄ 字号 评论关闭
 “授人以鱼,不如授人以渔”;

“现在的程序员怎么越来越素质低下了撒,经常在BBS上看到我不要解决方法,我只要源代码,TNND,
方法都给你了,实现还要人写阿,说得不好听得话,你娶个老婆不会gan,你爸爸告诉你方法,你怎么
就不让你爸爸替你gan呢,真是垃圾,别人时间不值钱阿,凭什么让你不劳而获?”

下面在www.delphibbs.com上看到的一个简单问题的贴子,发贴人就是这类人,

URL:http://www.delphibbs.com/delphibbs/dispq.asp?lid=3524495
问题:移动公司的一道简单面试题,居然很多大学生做不出 ( 积分:1, 回复:34, 阅读:1032 )
分类:数据库-文件型 ( 版主:hbezwwl, bubble ) 
来自:gigi788, 时间:2006-8-3 16:29:00, ID:3524495

以下为问题描述和解题方法:

问题:A和B,A说:我是你现在这个年龄的时候啊,你才4岁。B说:等我到了你现在这个年龄呀,你都67岁了。那A和B现在分别是几岁?  

        假定
           A: x岁
           B: y岁
           A和B相差:z岁

        那么
           x-y=z
           y-4=z
           67-x=z

        从而
           x-y=y-4   =>x=2y-4 =>x=2*(71-x)-4=138-2x=>x=138/3=46
           67-x=y-4  =>y=71-x                                  =>y=71-46=25
       
             
1、C#实现代码:
private void button1_Click(object sender, EventArgs e)
        {
            int x;
            int y;
            int z;
            for (x = 1; x <= 67; x++)
            {
                for (y = 1; y <= 67; y++)
                {
                    z = x - y;
                    if ((67 - x) == z && (y - 4) == z)
                    {
                        MessageBox.Show("A年龄:" + x.ToString() + " 岁,B年龄:" + y.ToString() + " 岁");
                    }
                }
            }
        }
       
       
2、Delphi实现:
procedure TForm3.Button1Click(Sender: TObject);
var
  x:integer;
  y:integer;
  z:integer;
begin
  for x:=1 to 67 do
  begin
    for y:=1 to 67 do
    begin
      z:=x-y;
      if(((67-x)=z)and((y-4)=z)) then
      ShowMessage('A年龄:' + IntToStr(x) + ' 岁,B年龄:' + IntToStr(y) + ' 岁');
    end;
  end;
end;

3、JavaScript实现:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>计算年龄</title>
</head>
<script langguage="javascript" >
function calculate_Age()
{   var x;
    var y;
    var z;
    for (x = 1; x <= 67; x++)
    {
      for (y = 1; y <= 67; y++)
      {
        z = x - y;
        if ((67 - x) == z && (y - 4) == z)
        {
          alert("A年龄:" + x + " 岁,B年龄:" + y + " 岁");
        }
      }
    }
}
</script>
<body>
<input type="button" name="Submit" value="计算" onclick="calculate_Age();" />
</body>
</html>

4、VBScript实现:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>计算年龄</title>
</head>
<body>
<input type="button" name="button1" value="计算">
<script language="vbscript">
<!--
sub button1_onclick
  dim x
  dim y
  dim z  
  for x = 1 to 67  
    for y = 1 to 67      
      z = x - y
      if (((67 - x) = z) and ((y - 4) =z)) then        
        MsgBox("A年龄:" & CStr(x) & " 岁,B年龄:" & CStr(y) & " 岁")
      end if  
     next
   next  
end sub
-->
</script>
</body>
</html>

5、PHP实现:

<html>
<head>
 <title>计算年龄</title>
</head>
<body>
<?php
   for ($x = 1; $x <= 67; $x++)
   {
         for ($y = 1; $y <= 67; $y++)
         {
           $z=$-$y;          
           if ((67 - $x) == $z && ($y - 4) == $z)
        {
         echo "A年龄:" + strval($x) + " 岁,B年龄:" + strval($y) + " 岁";
          }          
        }
    }
?>
</body>
</html>

6、其他语言代码,你想要还可以给你实现一下,哼哼。。。   

抱歉!评论已关闭.