课上练习 script

<!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=utf-8" />
<title>无标题文档</title>
</head>

<body>
判断是否是闰年<br />
请输入年份:<input type="number" id="text" /><input type="button" value="检查是否是闰年" onclick="check()" /><br />
<br />
<br />
<br />
<br />
判断是否成年
<br />
请输入年龄:<input type="number" id="age" /><input type="button" value="判断是否成年" onclick="check()" /><br />
<br /><br />
你能跑过豹子么?<input type="text" id="jieguo" /><input type="button" value="你能跑过豹子么" onclick="nengfou()" />
<br />
xyz三个整数,从小到大输出<br />
请输入x:<input type="number" id="x1"/>
请输入y:<input type="number" id="y1" />
请输入z:<input type="number" id="z1" />
<input type="button" value="从小到大输出xyz" onclick="bijiao1()" />

<br />

xyz三个整数,从小到大输出<br />
请输入x:<input type="number" id="x"/>
请输入y:<input type="number" id="y" />
请输入z:<input type="number" id="z" />
<input type="button" value="从小到大输出xyz" onclick="bijiao2()" />
<script>
function bijiao2()
{
var x=document.getElementById("x").value
var y=document.getElementById("y").value
var z=document.getElementById("z").value
if(x!=""&&y!=""&&z!="")
{
if(x%1==0&&y%1==0&&z%1==0)
{
var a
if(x>y)
{
a=y
y=x
x=a
}
if(x>z)
{
a=z
z=x
x=a
}
if(y>z)
{
a=z
z=y
y=a
}

{alert(x+" "+y+" "+z)}
}
else
{
alert("请输入整数")
}
}
else
{
alert("请输入内容")
}
}
</script>

<br />
姓名:<input type="text" id="xingming" /><br />
成绩:<input type="number" id="chengji"/><input type="button" value="jieguo" onclick="chaxun()"/><br />
<script>
function chaxun()
{
var chengji=document.getElementById("chengji").value
var xingming=document.getElementById("xingming").value
if(xingming!=""&&chengji!="")
{
if(chengji>=0&&chengji<=100)
{
if(chengji==100)
{
alert("恭喜你"+xingming+","+"满分通过")
}
else if(chengji>=80&&chengji<100)
{
alert(xingming+","+"你很优秀")
}
else if(chengji>=60&&chengji<80)
{
alert(xingming+","+"你的成绩是良好")
}
else if(chengji>=50&&chengji<60)
{
alert(xingming+","+"再接再厉")
}
else
{
alert(xingming+","+"你是笨蛋么")
}
}
else
{
alert("输入有误")
}
}
else
{
alert("请输入内容")
}
}
</script>
</body>
</html>
<script>
function check()
{
var year=document.getElementById("text").value;
if(year!="")
{
if(year>0&&year<10000)
{
if(year%1==0)
{
if(year%4==0&&year%100!==0 || year%400==0)
{
alert("闰年")
}
else
{
alert("平年")
}
}
else
{
alert("请输入整数")
}
}
else
{
alert("您输入值不在年份范围内")
}
}
else
{
alert("此处不能空白")
}
}
function check()
{
var age=document.getElementById("age").value
if(age!="")
{
if(age>0&&age<150)
{
if(age%1==0)
{
if(age<18)
{
alert("未成年")
}
else
{
alert("成年")
}
}
else
{
alert("整数")
}
}
else
{
alert("超出范围")
}
}
else
{
alert("不能空白")
}

}

function nengfou()
{
var jieguo=document.getElementById("jieguo").value
if(jieguo!="")
{
if(jieguo=="能")
{
alert("你比禽兽还禽兽")
}
else if(jieguo=="不能")
{
alert("你禽兽不如")
}
else
{
alert("输入有误")
}
}
else
{
alert("请输入有效内容")
}
}

function bijiao1()
{
var x1=document.getElementById("x1").value
var y1=document.getElementById("y1").value
var z1=document.getElementById("z1").value
if(x1!=""&&y1!=""&&z1!="")
{
if(x1%1==0&&y1%1==0&&z1%1==0)
{
if(x1>y1&&x1>z1)
{
if(y1>z1)
{
alert(z1+" "+y1+" "+x1)
}
else
{
alert(y1+" "+z1+" "+x1)
}
}
else if(y1>x1&&y1>z1)
{
if(x1>z1)
{
alert(z1+" "+x1+" "+y1)
}
else
{
alert(x1+" "+z1+" "+y1)
}
}
else if(z1>x1&&z1>y1)
{
if(x1>y1)
{
alert(y1+" "+x1+" "+z1)
}
else
{
alert(x1+" "+y1+" "+z1)
}
}
}
else
{
alert("请输入整数")
}
}
else
{
alert("请输入数字")
}
}

</script>

时间: 2025-01-25 03:16:29

课上练习 script的相关文章

智慧解析第03课上:战国故事 相如出世

智慧解析第03课上:战国故事 相如出世,布布扣,bubuko.com

课上练习

package 课上作业; import java.util.InputMismatchException; import java.util.Scanner; public class Test { public static void main(String[] args) { for(int m=0;;) { int judge=0; Scanner in=new Scanner(System.in); int n; System.out.println("请输入帖子的个数:")

Construct Binary Tree from Inorder and Postorder Traversal (算法课上的题)

Construct Binary Tree from Inorder and Postorder Traversal 这道题之前算法课上好像遇到过,思路也很简单的. 思路:后序序列的最后一个元素就是树根,然后在中序序列中找到这个元素(由于题目保证没有相同的元素,因此可以唯一找到),中序序列中这个元素的左边就是左子树的中序,右边就是右子树的中序,然后根据刚才中序序列中左右子树的元素个数可以在后序序列中找到左右子树的后序序列,然后递归的求解即可.(在去除了根节点之后,中序遍历和后序遍历的前N个树都是

课上1.0

课上:  课上比较差脑子一片混乱,定义了一个数组接收hello word,本来想用ASCII码值变化来实现大小写改变,结果做到一半发现程序运行有问题不能直接用, 然后就想用指针,结果没什么头绪就下课了 课下: 百度问题,百度报错意思 #include <stdio.h> #include <stdlib.h> int main(){ char str[] = "hello word"//定义一个数组放进字符串 printf("%s\n",st

课上的程序补充

#include<stdio.h> void funstr(char *p) { *p=*p-32; *(p+6)=*(p+6)-32; printf("%s\n",p); int i; for(i=0;i<12;i++) printf("%c",*(p++)); } int main() { char str[]="hello world!"; funstr(str); } Hello World! Hello World!

课上程序的补充

#include<stdio.h> #include<string.h> int main() { void funstr(char a[]); char str[]="hello world"; str[0]-=32; str[6]-=32; funstr(str); } void funstr(char a[]) { char *p; p=a; int n; n=strlen(a); while(n) { printf("%c",*p);

课上作业。

<C语言程序设计>实验报告 学 号 160809229 姓 名 马寅武 专业.班 计科16-2班 学 期 2016-2017 第1学期 指导教师 黄俊莲 吉吉老师 实验地点 C05 机 器 号 时 间 2016年 10 月 13 日 6 周 周四 1.2 节 截至日期 2016.10.13 11:50 实验任务清单 1.实验3-1 分别使用while循环.do while循环.for循环求(即求1+2+3+ ……+100) 2.实验3-2分别使用while循环.do while循环.for循环

ACM 动态规划 最大路径得分(课上)

问题: 给定一个具有N层的数字三角形如下图,从顶至底有多条路径,每一步可沿左斜线向下或沿右斜线向下,路径所经过的数字之和为路径得分,请求出最大路径得分.        7        3 8     8 1 0   2 7 4 4   4 5 2 6 5 用到记忆化搜索的方式,可以增加效率,用递归算法太慢了... /* 课上题目 最大路径得分 */ # include <iostream> using namespace std; const int MAX = 1e4; int dp[MA

ACM 动态规划 最长上升子序列(课上)

输入数据 输入的第一行是序列的长度N (1 <= N <= 1000).第二行给出序列中的N 个整数,这些整数的取值范围都在0 到10000. 输出要求 最长上升子序列的长度. 输入样例 7 1 7 3 5 9 4 8 输出样例 4 /* 课上题目 最长上升子序列 */ # include <iostream> using namespace std; const int MAX = 1e5; int a[MAX + 10]; int len[MAX + 10]; int main