Java-for循环打印九九乘法表
Java打印九九乘法表
public class forDemo04 {
public static void main(String[] args) {
//练习3:打印九九乘法表
/*
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12 4*4=16
1*5=5 2*5=10 3*5=15 4*5=20 5*5=25
1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
*/
//思路:
//1.九九乘法表中包含参数 1~9 和运算符 *和 =
//2.用for循环1-9,然后嵌套一个for循环1-9
//3.去掉重复项:将嵌套的判断条件改为j<=i
//4.使用\t 和 换行调整成上面的样式
for (int i = 1; i < 10; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j+"*"+i+"="+(j*i)+"\t");
}
System.out.println();
}
}
}
Java-for循环打印九九乘法表的更多相关文章
- 写一个方法,用一个for循环打印九九乘法表
public class MultiplicationTable { /** * @description 写一个方法,用一个for循环打印九九乘法表 * @author wangkun * ...
- for循环打印九九乘法表
学习目标: 熟练掌握 for 循环的使用 例题: 需求:打印九九乘法表 代码如下: // 九九乘法表 // row 为行,col为列 for(int row = 1; row < 10; row ...
- 【Java】Java_15 打印九九乘法表
使用For循环嵌套即可打印九九乘法表 以下是具体代码: /** * 打印九九乘法表 */ package com.oliver.test; public class TestMultiplicatio ...
- 用JS的for循环打印九九乘法表
需要使用两个for循环嵌套,代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta cha ...
- lua学习之循环打印九九乘法表
--第4题 输出99乘法表 function PrintMulitiplyTable() , do local res = {} local str = "" , i do res ...
- python3:使用for循环打印九九乘法表
for i in range(1, 10): for j in range(1, i + 1): print(j, '*', i, '=', i * j, end=" ") #en ...
- python while 循环打印九九乘法表
方向一 i = 1 while i <= 9: j = 1 while j <= i print('%d*%d = %2d'%( j,i ,i*j),end='') j += 1 prin ...
- 用for循环打印九九乘法表(for嵌套循环)
package com.Summer_0416.cn; /** * @author Summer * */ public class Test_Method10 { public static voi ...
- JavaScript-双层for循环打印九九乘法表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- WPF Animation For SizeChanged Of UIElement
效果图 学到一个新词: Show me the money 背景 这几天查资料,看到 CodeProject 上面的一篇 Post <Advanced Custom TreeView Layou ...
- Python 遭遇 ProxyError 问题记录
最近遇到的一个问题,在搞清楚之后才发现这么多年的 HTTPS_PROXY 都配置错了! 起因 想用 Python 在网上下载一些图片素材,结果 requests 报错 requests.excepti ...
- CPU饥饿与线程饥饿
线程饥饿: 进程无法得到资源,(cpu或者io资源或者别的什么资源),所以无法进行下去 比如说读者写者问题,如果读者优先,那么写者可能会饿死. 又比如操作系统概念的一道习题. 用broadcast可能 ...
- POJ - 3665 icow
Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player ...
- sdut3562-求字典序最小的最短路 按顶点排序后spfa的反例
首先我们可以这么搞...倒序建图,算出源点s附近的点距离终点的距离,然后判断一下,终点是否能跑到源点 能跑到的话呢,我们就判断s周围的点是否在最短路上,然后我们选编号最小的点就好了 代码 #inclu ...
- Linux下开发STM32单片机
一开始学习51单片机就是用的MDK这个IDE软件,IDE软件虽然看起来直观好像更加容易入门(因为有界面看起来很形象),但是实际上IDE却是向我们这些入门人员隐藏了背后真实存在的过程,让我们以为编译就是 ...
- 014.NET5_MVC_Razor扩展Html控件02
第二种方法: 通过一个后台方法,返回一个不存在的html标签字符串,在读取的时候,通过后台方法去渲染成需要的标签和内容: 1. 定义一个普通类,类名称建议以TagHelper结尾,并且给类添加特性[H ...
- Building an IMAP Email Client with PHP
1 Building an IMAP Email Client with PHP http://www.toptal.com/php/building-an-imap-email-client-wit ...
- js console.log all in one
js console.log all in one this & arguments "use strict"; /** * * @author xgqfrms * @li ...
- Typescript & React & Vue
Typescript & React & Vue Typescript & React https://facebook.github.io/create-react-app/ ...