复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>杨氏矩阵查找</title>
</head>
<body>
<script language="javascript">
function xunhuan()
{
var m = parseInt(document.getElementsByTagName("input")[0].value)||document.getElementsByTagName("input")[0].getAttribute("value");
var n = parseInt(document.getElementsByTagName("input")[1].value)||document.getElementsByTagName("input")[1].getAttribute("value");
var t = parseInt(document.getElementsByTagName("input")[2].value)||document.getElementsByTagName("input")[2].getAttribute("value");
    if(m >= 1&&n <= 1000&&t >= 1&&t <= 1000000)
    {
        var num = 2;
        for(var x = 0;x < m;x++)
        {
            for(var y = 0;y < n;y++)
            {
                document.write((num++)+" ");
            }
            document.write("<br/>");
        }
        var a=new Array();
        for(var e = m*n+1;e > 1; e--)
        {
            a.splice(0,0,e)
        }
        chazhao(a,t);
    }
    else
    {
        alert("不符合要求,请重新输入");
    }
}
function chazhao(a,number)
{
    document.write(isCon(a, number));
    function isCon(a, number)
    {
        for(var i=0; i<a.length; i++)
        {
            if(a[i] === number)
            {
                return String(true);
            }
        }
        return String(false);
    }
}
</script>
<form>
<p>矩阵行数:<input type="text" name="矩阵行数" value=3 />&nbsp;矩阵列数:<input type="text" name="矩阵列数" value=3 /></p>
<p>查询数字:<input type="text" name="查询数字" value=1 /></p>
<input type="button" onclick="xunhuan()" value="数组" />
</form>
</body>
</html>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com