JAVA基础编程之打印99乘法表
需求:打印9*9乘法表
技术考核:
1.for嵌套循环
代码:
// 打印99乘法表
public static void print99Table() {
System.out.println("99乘法表");
System.out.print("\\" + " ");
for (int i = 1; i <= 9; i++) {
System.out.print(i + " ");
}
System.out.println();
for (int i = 1; i <= 9; i++) {
System.out.print(i + " ");
for (int j = 1; j <= 9; j++) {
if (j <= i) {
int value = i * j;
if (String.valueOf(value).length() >= 2) {
System.out.print(i * j + " ");
} else {
System.out.print(i * j + " ");
}
}
}
System.out.println();
}
}
效果图:

JAVA基础编程之打印99乘法表的更多相关文章
- Java基础编程题——打印九九乘法表
package com.yangzl.basic; /** * 九九乘法表 * @author Administrator * */ public class Nine_Nine_Multiplica ...
- JS基础_打印99乘法表
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Java流程控制:增强for循环,break&continue,打印99乘法表
增强for循环:java5引入了一种主要用于数组或集合的增强for循环for(声明语句:表达式){//代码句子} 声明语句:声明新的局部变量,该变量的类型必须和数组元素的类型匹配.其作用域限定在循环语 ...
- Python之打印99乘法表
本脚本实现打印99乘法表 #!/usr/bin/python #9*9 for i in range(1,10): print for j in range(1,i+1): print "% ...
- 使用for循环打印9×9乘法表
请使用for循环,倒序打印9×9乘法表. 打印结果如下图所示: 使用for循环打印9×9乘法表 #include <stdio.h> int main() { int i, j, resu ...
- 用JS,打印99乘法表
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 打印99乘法表-python
题目:如何打印出阶梯状的99乘法表? 题解: #coding:utf-8def multiplication_tables(num):#for i in range(1,10): for j in r ...
- java使用普通算法实现99乘法表,使用递归实现99乘法表
public class recursionTest { public static void main(String[] args) { //jiujiu(); m(9); } /* * for循环 ...
- python中使用for循环,while循环,一条命令打印99乘法表
用for循环打印九九乘法表: 1 2 3 4 5 6 for i in range (1,10): for j in range(1,10): print(j,"x& ...
随机推荐
- C#编程 Excel操作
使用OLEDB操作Excel,关于OLEDB介绍参考http://www.cnblogs.com/moss_tan_jun/archive/2012/07/28/2612889.html 连接字符串: ...
- C学习笔记-gcc
GNU CC(通常称为GCC)是GNU项目的编译器,它能够编译C.C++语言编写的程序 gcc的优点 使用gcc,程序员可以控制生成二进制执行文件中调试代码的数量和类型. 和其他编译器一样,gcc也可 ...
- python笔记之元祖
元祖创建使用圆括号括起来,中间元素使用逗号隔开 如:tuple1 = (1,2,3,4) tuple2 = () 空元祖 #!/usr/bin/env python #-*-coding:utf-8- ...
- Linux基础命令---间歇执行命令---watch
[watch] watch指令可以间歇性的执行程序,将输出结果以全屏的方式显示,默认是2s执行一次. watch指令下发后,将会一直被执行,直到被中断. [语法] watch \ [-d h v t] ...
- idea导入eclipse的web项目
idea导入eclipse的web项目 一.导入自己的web项目 步骤:File->New->Project from Existing Source... 二.选择项目的所在位 ...
- (转)C++ bitset用法
今天做题发现要用到bitset,找到一篇介绍的巨好的文章. 转载自:https://www.cnblogs.com/magisk/p/8809922.html C++的 bitset 在 bitset ...
- Interval List Intersections
Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order ...
- [转帖]$PWD 和 $(pwd)
$PWD 和 $(pwd) https://blog.csdn.net/shaojwa/article/details/51894980 细节决定成败. 注意两个效果一样,但是注意大小写,PWD是 ...
- [转帖]IBM收购红帽价格是多少?是否会形成垄断企业?会存在什么不安因素?
http://www.techweb.com.cn/it/2019-07-10/2743776.shtml 国产的linux 用centos源的 如何是好呢.. 蓝色巨人IBM官方宣布,已经正式完成对 ...
- Go语言流程控制中的break,continue和goto(七)
break(跳出循环) break用于跳出整个循环,如下: func main() { ;i<;i++{ { break } fmt.Println(i) } } // 0 1 2 3 代码里只 ...