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 ...
随机推荐
- 2020ICPC·小米 网络选拔赛第一场
2020ICPC·小米 网络选拔赛第一场 C-Smart Browser #include <string> #include <iostream> std::string s ...
- SpringBoot整合Swagger初探
当下的Web项目大都采用前后端分离+分布式微服务的架构.前后端分离式的开发中,前端开发人员要与后端开发人员协商通信接口,约定接口规范.因此对于开发人员来说能够维持一份及时更新且完整全面的API文档会大 ...
- codeforces 1039B Subway Pursuit【二分+随机】
题目:戳这里 题意:一个点在[1,n]以内,我们可以进行4500次查询,每次查询之后,该点会向左或向右移动0~k步,请在4500次查询以内找到该点. 解题思路:一边二分,一边随机. 交互题似乎有好多是 ...
- HDU - 5115 Dire Wolf (非原创)
Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not ...
- element-ui dialog loading
element-ui dialog loading 指令方式 服务方式 v-loading 当使用指令方式时,全屏遮罩需要添加fullscreen修饰符(遮罩会插入至 body 上),此时若需要锁定屏 ...
- Trailing commas
Trailing commas 尾逗号 https://caniuse.com/?search=trailing commas ESlint { "comma-dangle": [ ...
- JavaScript 注释规范
JavaScript 注释规范 总原则 As short as possible(如无必要,勿增注释).尽量提高代码本身的清晰性.可读性. As long as necessary(如有必要,尽量详尽 ...
- HTML5 in depth
HTML5 in depth Content Models Web Storage web storage 存储用户信息, 替代 cookies LocalStorage SessionStorage ...
- Chrome & console.log & color & js
Chrome & console.log & color & js console.log & color // OK log(`%cchat_list =\n%c${ ...
- ES2019 features & ES-Next
ES2019 features & ES-Next https://github.com/tc39/proposals Object.fromEntries(), trimStart(), t ...