/*
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. QT 读写二进制 (数值)高位在前

    在人们的计数规则中,一般都认为高位在前,即往前的地位大,如123,我们认为是一百二十三, 但在计算机中数值是以二进制存储的,字节是最小的存储单位,如int(32位),占4个字节,每个字节有八位, 24 ...

  2. Java:多线程,线程池,使用CompletionService通过Future来处理Callable的返回结果

    1. 背景 在Java5的多线程中,可以使用Callable接口来实现具有返回值的线程.使用线程池的submit方法提交Callable任务,利用submit方法返回的Future存根,调用此存根的g ...

  3. 在Windows Server 2012 上安装Exchange 2013 服务器

    前文:http://www.cnblogs.com/Liangw/archive/2011/09/19/2559944.html 安装准备: 1.加入一个存在的域(?如何建立一个域) 2.登录Wind ...

  4. Android手机应用程序开发环境配置(Eclipse+Java+ADT)

    参考: Java手机游戏开发实例简明教程 http://dev.10086.cn/blog/?uid-82940-action-viewspace-itemid-1772 Eclipse下载: htt ...

  5. STL之algorithm、numeric、functional

    <algorithm>是所有STL头文件中最大的一个,其中常用到的功能范围涉及到比较.交换.查找.遍历操作.复制.修改.反转.排序.合并等等. <numeric>体积很小,只包 ...

  6. asterisk错误排查

    1.查看某个模块是否被包含在编译选项里了: See menuselect.makeoptsIf you see chan_sip in the MENUSELECT_CHANNELS option, ...

  7. wikioi 1154 能量项链 (2006年NOIP全国联赛提高组)

    题目描述 Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子 ...

  8. 最大流加强 dinic+当前弧优化

    qyy开始练习网络流啦 , 啊 ,蒟蒻只会套版 ,很裸的题 , 我连题都不想发了 ,可以参考我的代码(虽然我也是看的别人的 #include <iostream> #include < ...

  9. Python - 字典(dict) 详解 及 代码

    字典(dict) 详解 及 代码 本文地址: http://blog.csdn.net/caroline_wendy/article/details/17291329 字典(dict)是表示映射的数据 ...

  10. 封装Unity3d的dll时的经验总结

    部分时候,我们需要自己封装一些小工具来简化我们的工作. 实验时,偶然发现Unity3d的console在双击进行debug信息的输出定位时,只能跟进到dll的上一层,因此我们可以将unity3d自带的 ...