标题:程序有看不懂的地方
取消只看楼主
kuaisha
Rank: 2
等 级:论坛游民
帖 子:120
专家分:30
注 册:2016-8-3
结帖率:100%
 问题点数:0 回复次数:0 
程序有看不懂的地方

#include <stdio.h>
#define COLS 5
void twice(double ( * )[COLS], int );
void display(double (*)[COLS], int );

int main(void)
{
 double array[3][COLS] = { {1.1, 2.2, 3.3, 4.4, 5.5},
       {6.6, 7.7, 8.8, 9.9, 10.10},
       { 11.11, 12.12, 13.13, 14.14, 15.15} };
 puts("before:");
 display(array, 3);
 twice(array, 3);
 puts("\nafter:");
 display(array, 3);

    return 0;
}  

void twice(double ( *p )[COLS], int rows)//在这个自定义函数中(*p)是什么意思?是变量名还是列?
{
 int i,j;
 for(i=0;i<rows;i++)
  for (j=0; j<COLS; j++)
   p[i][j] = 2* p[i][j];
}

void display(double ( *p )[COLS], int rows)
{
 int i,j;
 for(i=0;i<rows;i++)
 {
  for (j=0; j<COLS; j++)
   printf("%g\t",p[i][j]);//数组名不是array吗,为什么它的是p,而且还可以输出?
  printf("\n");
 }
}
搜索更多相关主题的帖子: void double int display array 
2017-12-02 22:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-483047-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.246945 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved