| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1271 人关注过本帖
标题:数组指针变量形参与实参的传递
取消只看楼主 加入收藏
a2388089233
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-5-29
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
数组指针变量形参与实参的传递
#include  <stdlib.h>
#include  <stdio.h>
#define   N   10
double fun(double  *x)
{ int  i, j;    double  av, y[N];
  av=0;
  for(i=0; i<N; i++)
/**********found**********/
    av+=x[i]/N;
  for(i=j=0; i<N; i++)
    if( x[i]<av ){
      y[j]=x[i]; x[i]=-1;
/**********found**********/
      j++;
    }
  i=0;
  while(i<N)
  {  if( x[i]!= -1 ) y[j++]=x[i];
/**********found**********/
     i++;
  }
  for(i=0; i<N; i++)x[i] = y[i];
  return  av;
}
main()
{ int  i;     double  x[N];
  for(i=0; i<N; i++){ x[i]=rand()%50; printf("%4.0f ",x[i]);}
  printf("\n");
  printf("\nThe average is: %f\n",fun(x));
  printf("\nThe result :\n",fun(x));
  for(i=0; i<N; i++)  printf("%5.0f ",x[i]);
  printf("\n");
}
子程序中x[i]应该是主程序中x[i]的地址还是其值?为什么
搜索更多相关主题的帖子: include double return 
2017-05-29 01:34
快速回复:数组指针变量形参与实参的传递
数据加载中...
 
   



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

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