首页 > 其他分享 >求二元数组各行元素的平均值

求二元数组各行元素的平均值

时间:2023-08-10 21:32:03浏览次数:35  
标签:各行 二元 int double sum srand arr NULL 平均值


int main()
{
	int arr[3][4]={0};
	int sum=0;
	int i=0;
  int j=0;
	double ave=0.0;
	srand(time(NULL));
	for(i=0;i<3;i++)
	{
		ave=0;
		for(j=0;j<4;j++)
		{
			arr[i][j]=rand()%20+1;       
			printf("%d ",arr[i][j]);
			ave+=arr[i][j];
		}
		ave/=4;
		printf("ave:%.2f\n",ave);
  }

标签:各行,二元,int,double,sum,srand,arr,NULL,平均值
From: https://blog.51cto.com/u_16190077/7040211

相关文章