复制代码 代码如下:
<!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 /> 矩阵列数:<input type="text" name="矩阵列数" value=3 /></p>
<p>查询数字:<input type="text" name="查询数字" value=1 /></p>
<input type="button" onclick="xunhuan()" value="数组" />
</form>
</body>
</html>
<!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 /> 矩阵列数:<input type="text" name="矩阵列数" value=3 /></p>
<p>查询数字:<input type="text" name="查询数字" value=1 /></p>
<input type="button" onclick="xunhuan()" value="数组" />
</form>
</body>
</html>
标签:
杨氏矩阵,查找
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“杨氏矩阵查找的JS代码”评论...