java打印三角,乘法口诀
来源:互联网 发布:mac rmvb转换 编辑:程序博客网 时间:2024/05/18 00:11
//打印正三角public class helloworld { public static void main(String[] args) { String cell="*"; String space=" "; for (int lines=1; lines<=9; lines++) { // 只有偶数时才打印 if (lines%2==0) { // 打印空格 for (int spaces=1; spaces<=(9-lines)/2; spaces++) { System.out.print(space); } // 打印三角 for (int cells=1; cells<=lines; cells++) { System.out.print(cell); } // 打印空格 for (int spaces=1; spaces<=(9-lines)/2; spaces++) { System.out.print(space); } System.out.println(""); } } }}
// 打印倒三角public class helloworld { public static void main(String[] args) { String cell="*"; String space=" "; for (int lines=9; lines>=1; lines--) { // 只有偶数时才打印 if (lines%2==0) { // 打印空格 for (int spaces=1; spaces<=(9-lines)/2; spaces++) { System.out.print(space); } // 打印三角 for (int cells=1; cells<=lines; cells++) { System.out.print(cell); } // 打印空格 for (int spaces=1; spaces<=(9-lines)/2; spaces++) { System.out.print(space); } System.out.println(""); } } }}
// 打印乘法口诀public class helloworld { public static void main(String[] args) { for (int lines=1; lines<=9; lines++) { for (int columns=1; columns<=lines; columns++) { System.out.print(columns+"*"+lines+"="+columns*lines+"\t"); } System.out.println(); } }}
附上图片:
0 0
- java打印三角,乘法口诀
- java 打印乘法口诀
- Java打印乘法口诀
- java打印乘法口诀
- c打印乘法口诀和三角
- Java实现打印乘法口诀
- java打印乘法口诀表
- Java:输出乘法口诀(上三角)
- 利用java打印乘法口诀表
- java实现乘法口诀和打印菱形
- JAVA打印乘法口诀(完美排序)
- 【C语言】打印乘法口诀表(正三角,倒三角)
- 乘法口诀打印
- 乘法口诀打印
- 乘法口诀打印
- Python打印乘法口诀
- 打印一个乘法口诀
- 打印乘法口诀表
- setHomeButtonEnabled
- CSS hack技巧大全
- beyond
- Web前端开发实战1:二级下拉式菜单之CSS实现
- Machine Learning] 梯度下降法的三种形式BGD、SGD以及MBGD
- java打印三角,乘法口诀
- cloud service 心得: openstack, cloudinit和puppet
- poj 1155 TELE 基础题,树形背包
- 机器学习技法第三次作业
- Linux环境下安装和卸载软件的方法
- log4j(一) 生成日志文件
- 《UNIX编程艺术》--读书笔记
- 124 js 前台日期显示格式和操作 & js生成table
- 代码整理之ViewPager