/*
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. pl/sql 关于变量定义的问题

    1. create or replace procedure  test_prc(p_data_dt in date) IS e_name emp.ename%type;      begin sel ...

  2. 【HDOJ】1455 Sticks

    DFS.搜索以棍数为条件循环搜索较好,这样不会超时. #include <stdio.h> #include <string.h> #include <stdlib.h& ...

  3. Fixing common issues when hosting a .NET 4.0 WCF service in IIS 7

    http://sandrinodimattia.net/fixing-common-issues-when-hosting-a-net-4-0-wcf-service-in-iis-7/ Until ...

  4. Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍

    磁盘分区表.文件系统的查看.统计的工具很多,有些工具是多功能的,不仅仅是查看磁盘的分区表,而且也能进行磁盘分区的操作:但在本文,我们只讲磁盘分区的查看,以及分区的使用情况的查看:本文只是给新手上路之用 ...

  5. POJ --2104

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 34935   Accepted: 11134 Ca ...

  6. this用法

    this是js的一个关键字,随着函数使用场合不同,this的值会发生变化.但是总有一个原则,那就是this指的是调用函数的那个对象. 1.纯粹函数调用. function test() { this. ...

  7. div样式调整小结 转载

    1.多个div使用会自动换行,应该使用float属性  left : 对象浮在左边  right : 对象浮在右边 例如:  float: left  和 float: right 是两个div左右排 ...

  8. 未能导入activex控件,请确保它正确注册

    这个错误"未能导入activex控件,请确保它正确注册"昨天下午让我和我同事花费了3个小时来调试这个错误,在使用VS2010的winfrom编程时加入com组件的时候,报这个错误( ...

  9. sqlserver 遇到以零作除数错误的处理 不报错的解决方法

    使用sqlserver 的选项来禁止出现以零除的错误中断,让而让其为null set ansi_warnings offSET ARITHABORT offSET ARITHIGNORE on sel ...

  10. 20169210《Linux内核原理与分析》第三周作业

    本次作业也是分为两部分,第一部分是对实验楼<Linux基础入门>复习,第二部分为对课本18章的复习. 第一次学习实验楼的<Linux基础入门>时由于是第一次接触Linux,所以 ...