nest 'for' loop.
/*
nest for loop demo.
Note that,'upside' triangle controls 'inner condition'.
*/
import kju.print.Print;
public class Pyramid {
public static void main(String[] args) {
upsideNumbers(5);
Print.println("------------------");
multiplicationTable(3);
Print.println("------------------");
pyramid(5);
}
/*shape begins:
----*
---* *
--* * *
-* * * *
shape ends:*/
static void pyramid(int height){
for(int i = 0; i < height; i++) { //all rows.
for(int j = i; j < height - 1; j++) //vitual for '-'.
Print.print(" ");
for(int j = 0; j <= i; j++)
Print.print("* ");
Print.println();
} //for(i)
} /*shape begins:
1
12
123
1234
12345
shape ends:*/
static void upsideNumbers(int height) {
for (int i = 1; i <= height; i++) {
for (int j = 1; j <= i ; j++)
Print.print(j);
Print.println();
}//for(i).
} /*shape begins:
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
shape ends:*/
static void multiplicationTable(int height){
for (int i = 1; i <= height; i++) {
for (int j = 1; j <= i; j++)
Print.print(j + "*" + i + "=" + (j * i) + "\t");
Print.println();
}//for(i)
}
}
nest 'for' loop.的更多相关文章
- 一种特殊场景下的HASH JOIN的优化为NEST LOOP.
应用场景: 有如下的SQL: select t.*, t1.ownerfrom t, t1where t.id=t1.id; 表t ,t1的数据量比较大,比如200W行.但是两张表能关联的行数却很少, ...
- The Node.js Event Loop, Timers, and process.nextTick() Node.js事件循环,定时器和process.nextTick()
个人翻译 原文:https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/ The Node.js Event Loop, Ti ...
- Oracle 三种连接方式 NESTED LOOP HASH JOIN SORT MERGE JOIN
NESTED LOOP: 对于被连接的数据子集较小的情况,嵌套循环连接是个较好的选择.在嵌套循环中,内表被外表驱动,外表返回的每一行都要在内表中检索找到与它匹配的行,因此整个查询返回的结果集不能太大( ...
- oracle多表连接方式Hash Join Nested Loop Join Merge Join
在查看sql执行计划时,我们会发现表的连接方式有多种,本文对表的连接方式进行介绍以便更好看懂执行计划和理解sql执行原理. 一.连接方式: 嵌套循环(Nested Loops (NL) ...
- The Node.js Event Loop, Timers, and process.nextTick()
The Node.js Event Loop, Timers, and process.nextTick() | Node.js https://nodejs.org/uk/docs/guides/e ...
- Atitit 解决Unhandled event loop exception错误的办法
Atitit 解决Unhandled event loop exception错误的办法 查看workspace/.metadata/.log org.eclipse.swt.SWTError: No ...
- Looper.prepare()和Looper.loop()
什么时候需要 Looper Looper用于封装了android线程中的消息循环,默认情况下一个线程是不存在消息循环(message loop)的,需要调用Looper.prepare()来给线程创建 ...
- PostgreSQL-PL/pgSQL-cursor,loop
将spam_keyword表word字段的字符全部拆分,只是利用过程语言完成循环的操作而已. create or replace function proc1() returns setof text ...
- archlinux 加载loop模块,且设定loop设备个数
如果loop模块没有编译进内核就要先加载loop模块 modprobe loop 然后更改/etc/modprobe.d/modprobe.conf(有些文章写是在/etc/modprobe.conf ...
随机推荐
- iframe详细用法
<iframe>是框架的一种形式,也比较常用到. 例子1.<iframe width=420 height=330 frameborder=0 scrolling=auto src= ...
- Git命令详解
一个中文git手册:http://progit.org/book/zh/ 原文:http://blog.csdn.net/sunboy_2050/article/details/7529841 前面两 ...
- HDU 1150 Machine Schedule
题目大意: 有两台机器A和B以及K个需要运行的任务.A机器有N种不同的模式,B机器有M种不同的模式,而每个任务都恰好在一台机器上运行. 如果它在机器A上运行,则机器A需要设置为模式xi,如果它在机器B ...
- git_share
linux 环境(192.168.8.58) 1. 生成rsa key $ ssh-keygen 如果你之前没有跑过这个文件, 接受默认选项即可. 这样你会在 ~/.ssh/下看到 id_rsa和id ...
- 【转】Unity3D NGUI事件 UIEvents
原创文章如需转载请注明:转载自 脱莫柔Unity3D学习之旅 QQ群:[119706192] 本文链接地址: Unity3D NGUI事件 UIEvents UIEvents-事件系统void OnH ...
- 6N137的使用
(1)引脚图 (2)功能表 (3)内部结构图 信号从2.3脚输入,反向偏置的光敏二极管受光照后导通,经过电流电压转换,输入到与门一端,与门另一端为使能端.由于输入信号为集电极开路,需要加上拉电阻.当使 ...
- mac上的键盘生活——快捷键列表
主界面 command + tab 切换程序 command + ` 在程序内切换界面 command + w 关闭界面 command + q 关闭程序 文本编辑 Com ...
- 【转】SVN linux命令及 windows相关操作(一)
从以下博客转载和整理: http://www.cnblogs.com/richcem/archive/2011/01/08/1930823.html http://blog.wpjam.com/m/t ...
- MongoDB简单操作
Hadoop核心技术厂商Cloudera将在2014/06推出hadoop Ecosystem与MongoDB的整合产品,届时MongoDB与ipmala及hbase,hive一起用; 开源linux ...
- 如何以非 root 用户将应用绑定到 80 端口-ssh 篇 » 社区 » Ruby China
如何以非 root 用户将应用绑定到 80 端口-ssh 篇 » 社区 » Ruby China 如何以非 root 用户将应用绑定到 80 端口-ssh 篇