html5--html实现乘法口诀表
html5--html实现乘法口诀表
总结:
1、多种情况问题:分情况讨论就出来了
2、汉字和数字的对应关系
3、相同的部分统一处理,不同的部分分别对待(这里用中间变量)
问题:九九乘法口诀
两点提示:
- Math.floor()方法可以将浮点数取整,比如Math.floor(3.6)==3;仅暂作了解;后续课程还会详细讲解相关内容。/li>
- 该练习综合运用了循环条件语句以及多个运算符,有一点难度,需要对之前的内容掌握比较熟练才可以理解。

代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>7-21 课堂演示</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script>
var str="";
var arr=['一','二','三','四','五','六','七','八','九','十'];
for(var i=1;i<10;i++){
for(var j=1;j<=i;j++){
var str0='';
if(i*j<10){
str0='得'+arr[i*j-1]
}else if(i*j==10){
str0='一十'
}else if (i*j<20) {
str0='十'+arr[i*j%10-1]
}else if (i*j%10==0) {
str0=arr[Math.floor(i*j/10)-1]+'十'
}else{
str0=arr[Math.floor(i*j/10)-1]+'十'+arr[i*j%10-1];
}
str+=arr[j-1]+arr[i-1]+str0+"    "
}
str+='<br/><br/>'
}
document.write(str) </script>
</body>
</html>
html5--html实现乘法口诀表的更多相关文章
- 用SQL打印乘法口诀表
--用SQL打印出乘法口诀表 declare @i int ,@j int --@i是乘法口诀的行数 --一共九行 begin --每次都是从1*开始,j每循环一次递增 )--print每次输出都会换 ...
- 用原生js实现一个页面乘法口诀表
今天我自己用js实现了一个页面乘法口诀表(如图)来共享给大家,做的不是很好,如果大家有新的想法可以跟我交流哦. 代码如下: <!doctype html><html lang=&qu ...
- JS一些小算术、1加到50、乘法口诀表、买鸡等
//从1加到50 for (var a=1,i=0;a<51; a++) {i=a+i} document.write(i);//1加到50 var num=0; for(var i=1;i&l ...
- javascript小程序——用嵌套循环来输出乘法口诀表
在学习javascript过程中,一开始接触循环语句时一般拿乘法口诀表来练手,这里我将自己的练习贴在这里,希望能给和我一样的初学者些许帮助,也希望大神们能够不吝指教. 首先,来看一下乘法口诀表是什么样 ...
- 简单的用js打印乘法口诀表
<script type="text/javascript"> //乘法口诀表 for (var i = 1; i < 10; i++) { for (var j ...
- Python打印乘法口诀表
思路:第一行:1*1,第二行:1*2.,2*2,第三行:1*3,2*3,3*3-- 最后一行:1*9,2*9,3*9,-9*9,以此类推,可以设2个数:i,j:让 i 从1循环到9,让 j 从1到小于 ...
- 用PHP如何实现这种乘法口诀表?
用PHP如何实现这种乘法口诀表? 1x1=1 ,1x2=2 ,1x3=3 ,.....,1x9=9 2x2=4 ,2x3=6 ,......,2x9=18 ........ ...... 8x8=64 ...
- iOS开发之 -- oc和swift下输出乘法口诀表
闲来无事,写着玩: oc: //乘法口诀表输出 ; i<=; i++) { ; j<=i; j++) { NSLog(@"%dx%d=%d\n",i,j,i*j); } ...
- Python 乘法口诀表
环境 Anaconda3 Python 3.6, Window 64bit 目的 输出9*9 乘法口诀表 代码 # -*- coding: utf-8 -*- ''' 1*1=1 2*1=2 2*2= ...
- php打印乘法口诀表
<?php $n=9; //动态控制乘法口诀表的行数 echo"<table>"; //外层循环控制行数 for($i=1;$i<=$n;$i++){ // ...
随机推荐
- Exact Change(01背包)
描述 Seller: That will be fourteen dollars. Buyer: Here's a twenty. Seller: Sorry, I don't have any ch ...
- Android ShapeDrawable之OvalShape、RectShape、PaintDrawable、ArcShape
Android ShapeDrawable之OvalShape.RectShape.PaintDrawable.ArcShape Android图形图像基础之OvalShape.RectShap ...
- HDU2069-Coin Change
Coin Change 这题题意和UVA674很像,但加了一个限制条件不能超过100个硬币.于是我们可以用d[i][j]来表示硬币数量为i时金钱总数为j时的方法总数,总钱不能超过250. const ...
- [Istio]Kubernetes集群部署Istio 1.0
大部分内容都是可以根据https://istio.io/docs/setup/kubernetes/quick-start/来处理的,这里主要谈部署时一些细节的问题 首先,当我们按照 istio 官方 ...
- 什么是Service Mesh?
转至大佬宋净明的博客:https://jimmysong.io/posts/what-is-a-service-mesh/ Service mesh 又译作 “服务网格”,作为服务间通信的基础设施层. ...
- [luoguP2622] 关灯问题II(状压最短路)
传送门 本以为是状压DP,但是有后效性. 所以写一手状压spfa #include <queue> #include <cstdio> #include <cstring ...
- android AlertDialog常见使用
android AlertDialog常见使用 简单提示框: AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); aler ...
- 事件和委托: 第 6 页 .Net Framework中的委托与事件
原文发布时间为:2008-11-01 -- 来源于本人的百度文章 [由搬家工具导入] .Net Framework中的委托与事件 尽管上面的范例很好地完成了我们想要完成的工作,但是我们不仅疑惑:为什么 ...
- 从零开始写STL—模板元编程之tuple
tuple Class template std::tuple is a fixed-size collection of heterogeneous values. It is a generali ...
- C# 通过T4自动生成代码
通过T4模板生成代码,运行时实现 关键代码段:Host using Microsoft.VisualStudio.TextTemplating; using System; using System. ...