- //
 
 - //  main.c
 
 - //  Test_01
 
 - //
 
 - //  Created by 蒋伟 on 16/5/14.
 
 - //  Copyright (c) 2016年 蒋伟. All rights reserved.
 
 - //
 
  
- #include <stdio.h>
 
  
- /**
 
 -  *  为二维数组按特定规则赋值
 
 -  *
 
 -  *  @param rows 行数
 
 -  *  @param cols 列数
 
 -  *  @param arr  目标数组
 
 -  */
 
 - void fuZhi(int rows, int cols, int arr[rows][cols]);
 
  
- /**
 
 -  *  打印二维数组元素
 
 -  *
 
 -  *  @param rows 行数
 
 -  *  @param cols 列数
 
 -  *  @param arr  目标数组
 
 -  */
 
 - void printfArr(int rows, int cols, int arr[rows][cols]);
 
  
- int main(int argc, const char * argv[]) {
 
 -     printf("请输入二位数组的行数和列数:");
 
 -     int rows, cols;
 
 -     scanf("%d%d",&rows,&cols);
 
 -     int arr[rows][cols];
 
 -     fuZhi(rows,cols,arr);
 
 -     printfArr(rows,cols,arr);
 
 -     return 0;
 
 - }
 
  
- /**
 
 -  *  为二维数组按特定规则赋值
 
 -  *
 
 -  *  @param rows 行数
 
 -  *  @param cols 列数
 
 -  *  @param arr  目标数组
 
 -  */
 
 - void fuZhi(int rows, int cols, int arr[rows][cols]){
 
 -     for(int i = 0; i < rows; i++){
 
 -         for(int j = 0; j < cols; j++){
 
 -             arr[i][j] = i * j + 10;
 
 -         }
 
 -     }
 
 - }
 
  
- /**
 
 -  *  打印二维数组元素
 
 -  *
 
 -  *  @param rows 行数
 
 -  *  @param cols 列数
 
 -  *  @param arr  目标数组
 
 -  */
 
 - void printfArr(int rows, int cols, int arr[rows][cols]){
 
 -     for(int i = 0; i < rows; i++){
 
 -         for(int j = 0; j < cols; j++){
 
 -             printf("%d\t",arr[i][j]);
 
 -         }
 
 -         printf("\n");
 
 -     }
 
 - }
 
  
 
 
 
 
 
  复制代码 
 
 |   
        
 
    
    
    
     
 
 |