当前位置:网站首页 - 特效代码 - ASP编程
  • <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>如何求两个数的最大公约数</title>
    </head>
    <body>
    <script language = "vbscript">
    function gys(x,y)
    dim r
    do  while y <> 0
    r=x mod y
    x=y
    y=r
    loop
    gys=x
    end function
    sub  btnshow_onclick()
    dim a,b,c
    a=clng(form1.text1.value)
    b=clng(form1.text2.value)
    c=gys(a,b)
    form1.text3.value=c
    end sub
    </script>
    <form name = "form1">
    输入第一个整数:<input type = "text" name = "text1" size = "10"><br>
    输入第二个整数:<input type = "text" name = "text2" size = "10"><br>
    求出最大公约数:<input type = "text" name = "text3" size = "10" readonly><br>
    <input type = "button" name = "btnshow"  value = "显示结果">
    </form>
    </body>
    </html>