/*
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.的更多相关文章

  1. 一种特殊场景下的HASH JOIN的优化为NEST LOOP.

    应用场景: 有如下的SQL: select t.*, t1.ownerfrom t, t1where t.id=t1.id; 表t ,t1的数据量比较大,比如200W行.但是两张表能关联的行数却很少, ...

  2. 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 ...

  3. Oracle 三种连接方式 NESTED LOOP HASH JOIN SORT MERGE JOIN

    NESTED LOOP: 对于被连接的数据子集较小的情况,嵌套循环连接是个较好的选择.在嵌套循环中,内表被外表驱动,外表返回的每一行都要在内表中检索找到与它匹配的行,因此整个查询返回的结果集不能太大( ...

  4. oracle多表连接方式Hash Join Nested Loop Join Merge Join

    在查看sql执行计划时,我们会发现表的连接方式有多种,本文对表的连接方式进行介绍以便更好看懂执行计划和理解sql执行原理. 一.连接方式:        嵌套循环(Nested  Loops (NL) ...

  5. 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 ...

  6. Atitit 解决Unhandled event loop exception错误的办法

    Atitit 解决Unhandled event loop exception错误的办法 查看workspace/.metadata/.log org.eclipse.swt.SWTError: No ...

  7. Looper.prepare()和Looper.loop()

    什么时候需要 Looper Looper用于封装了android线程中的消息循环,默认情况下一个线程是不存在消息循环(message loop)的,需要调用Looper.prepare()来给线程创建 ...

  8. PostgreSQL-PL/pgSQL-cursor,loop

    将spam_keyword表word字段的字符全部拆分,只是利用过程语言完成循环的操作而已. create or replace function proc1() returns setof text ...

  9. archlinux 加载loop模块,且设定loop设备个数

    如果loop模块没有编译进内核就要先加载loop模块 modprobe loop 然后更改/etc/modprobe.d/modprobe.conf(有些文章写是在/etc/modprobe.conf ...

随机推荐

  1. JqueryUI 为什么TypeError: $(...).slides is not a function

    单独写一个html发现一切没有问题,但放在自己的网页中作为一部分却出现了问题,最后发现是那些js文件引入顺序出现了问题,

  2. java.util.regex.Pattern的应用

    java.util.regex.Pattern 正则表达式的一种已编译的实现. 正则表达式通常以字符串的形式出现,它首先必须被编译为Pattern类的一个实例.结果模型可以用来生成一个Matcher, ...

  3. ConcurrentHashMap的get、put、size

    ConcurrentHashMap的get操作 get操作的高效之处在于整个get过程不需要加锁,get方法里将要使用的共享变量都定义成volatile. ConcurrentHashMap的Put操 ...

  4. android 常见分辨率(mdpi、hdpi 、xhdpi、xxhdpi )及屏幕适配注意事

    1.1 手机常见分辨率: 4:3VGA     640*480 (Video Graphics Array)QVGA  320*240 (Quarter VGA)HVGA  480*320 (Half ...

  5. 【HDOJ】3221 Brute-force Algorithm

    归来吧很好推导.T(n) = a^f(n-1)*b^f(n)%p.主要难点在于求mod和fibo.引用如下公式A^B%C = A^(B%phi(C) + phi(C))%C, 满足B>=phi( ...

  6. Delphi 6 Web Services初步评估

    Delphi 6 Web Services初步评估这是我刚到现在公司的时候(2001年8月份)所作的一份测试报告,现公布出来,希望能对大家有所帮助.因为当时d6刚刚发行,Web Service方面还存 ...

  7. 实现DataGridView实时更新数据

    ;).ToString() + ).ToString() + "秒";        } }}

  8. IE的表头固定/表头不动(使用expression)

    本文主要介绍在IE浏览器中,实现表头固定的一种方法.这种方法使用到了 IE 浏览器特有的 expression 方法. 表头固定DEMO1 主要代码: <style type="tex ...

  9. HDOJ 2012 素数判定

    Problem Description 对于表达式n^2+n+41,当n在(x,y)范围内取整数值时(包括x,y)(-39<=x < y<=50),判定该表达式的值是否都为素数. I ...

  10. 《A First Course in Probability》-chaper3-条件概率和独立性-P(·|F)是概率

    条件概率中的三个命题: 下面我们分条来解读一下这三个命题.