zoukankan      html  css  js  c++  java
  • 二维数组

    一. 二维数组遍历

    package test_1;

      public class test_7 {
        public static void main(String[] args) {
          int[][] arr = {{1,2,3},{5,6},{12,13,14}};

          for(int i=0; i< arr.length ; i++) {
            for(int j=0; j < arr[i].length ; j++){
              System.out.print(arr[i][j] +" ");
              }
            System.out.println("");
          }
      }

    }

    二. 二维数组求和

    package test_1;

      public class test_8 {

        public static void main(String[] args) {
          int[][] arr = {{33,44,55},{77,55,33},{33,55,77},{99,88,77}};
          int sum =0;
          for(int i=0; i< arr.length ; i++) {
            for(int j=0; j < arr[i].length ; j++){
              sum =sum +arr[i][j];
              }
          }System.out.println(sum);
    }

    }

    ******************************人因为有理想、梦想而变得伟大,而真正伟大就是不断努力实现理想、梦想*****************************
  • 相关阅读:
    c学习第6天
    c学习第5天
    c学习第4天
    c学习第1天
    20171009/20171010/20171011
    20171010
    20171008
    20171007
    20171006
    matrix
  • 原文地址:https://www.cnblogs.com/cloudLi/p/12864702.html
Copyright © 2011-2022 走看看