一个简单的for循环。。求解。。。

lichenlin521 2011-11-22 05:51:41
Write a program in Java using For Loop statement that will produce the following output.


输出是:
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16
...全文
51 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
MingJieChen 2011-11-22
  • 打赏
  • 举报
回复
public class ForTest
{
public static void main(String[] args)
{
for(int i=1;i<5;i++)
{
for(int j=1;j<5;j++)
{
System.out.print(i*j+"\t");
}
System.out.print("\n");
}
}
}
用for循环嵌套,第一个for控制要打印的行数,第二个for循环控制要打印的列
pp25210 2011-11-22
  • 打赏
  • 举报
回复


public class forLoop {
public static void main(String[] args) {

for(int i = 1; i < 5; i++){
for(int j = i; j <= 4 * i; j += i){
System.out.printf("%d ",j);
}
System.out.println("");
}

}

}


嘿嘿,给分吧!
denggougou 2011-11-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 funfenffun 的回复:]
Java code

public class Test14 {
public static void main(String[] args){
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
System.out.print(i*j+"\t");
……
[/Quote]+1
funfenffun 2011-11-22
  • 打赏
  • 举报
回复

public class Test14 {
public static void main(String[] args){
for(int i=1;i<5;i++){
for(int j=1;j<5;j++){
System.out.print(i*j+"\t");
}
System.out.println();
}
}

}

撒分贴
李狗蛋52635 2011-11-22
  • 打赏
  • 举报
回复
x*y

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧