• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

HSpringX

大学生入门笔记
  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

for循环(打印九九乘法表+增强for循环遍历数组)

public class Test7 {
    public static void main(String[] args) {
        //打印九九乘法表
        int s = 0;
        for (int i=1;i<10;i++){
            for (int u=1;u<=i;u++){
                s = i*u;
                System.out.print(i+"*"+u+"="+s+"\t");
            }
            System.out.println();
        }
        System.out.println("=========================================================================================");
        //增强for循环(遍历数组)
        int[] i ={10,20,30,40};
        for (int x:i){
            System.out.print(x+"\t");
        }

    }
}

输出:

1*1=1    
2*1=2    2*2=4    
3*1=3    3*2=6    3*3=9    
4*1=4    4*2=8    4*3=12    4*4=16    
5*1=5    5*2=10    5*3=15    5*4=20    5*5=25    
6*1=6    6*2=12    6*3=18    6*4=24    6*5=30    6*6=36    
7*1=7    7*2=14    7*3=21    7*4=28    7*5=35    7*6=42    7*7=49    
8*1=8    8*2=16    8*3=24    8*4=32    8*5=40    8*6=48    8*7=56    8*8=64    
9*1=9    9*2=18    9*3=27    9*4=36    9*5=45    9*6=54    9*7=63    9*8=72    9*9=81    
=========================================================================================
10    20    30    40    

 

posted on 2021-12-25 10:38  HSpringX  阅读(53)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3