当前位置:网站首页>Use the array to calculate the average of N numbers, and output the numbers greater than the average
Use the array to calculate the average of N numbers, and output the numbers greater than the average
2022-06-26 16:41:00 【Muzi..】
#include<stdio.h>
#include<stdlib.h>
#define N 10
double fun(double x[],double *y)
{
int i,j;
double av;
av=0.0;
for(i=0;i<N;i++)
{
av=av+x[i]/N;
}
for(i=j=0;i<N;i++)
{
if(x[i]>av)
y[j++]=x[i];
}
y[j]=-1;
return av;
}
main()
{
int i;
double x[N],y[N];
for(i=0;i<N;i++)
{
x[i]=rand()%50;
printf("%2.0f",x[i]);
printf("\n");
}
printf("\nthe average is:%f\n",fun(x,y));
for(i=0;y[i]>=0;i++)
{
printf("%5.1f",y[i]);
printf("\n");
}
}
边栏推荐
- Kept to implement redis autofailover (redisha)
- Développer un opérateur basé sur kubebuilder (démarrer)
- 【力扣刷题】单调栈:84. 柱状图中最大的矩形
- Tsinghua's "magic potion" is published in nature: reversing stem cell differentiation, and the achievements of the Nobel Prize go further. Netizen: life can be created without sperm and eggs
- Exquisite makeup has become the "soft power" of camping, and the sales of vipshop outdoor beauty and skin care products have surged
- Day10 daily 3 questions (2): count the number of the largest groups
- GUI+SQLServer考试系统
- JS tutorial using electron JS build native desktop application ping pong game
- 用Attention和微调BERT进行自然语言推断-PyTorch
- Stm32f103c8t6 realize breathing lamp code
猜你喜欢

【MATLAB项目实战】基于卷积神经网络与双向长短时(CNN-LSTM)融合的锂离子电池剩余使用寿命预测

Niuke Xiaobai monthly race 50

【力扣刷题】11.盛最多水的容器//42.接雨水

Natural language inference with attention and fine tuning Bert pytorch

GUI+SQLServer考试系统

Science | 红树林中发现的巨型细菌挑战传统无核膜观念

What is the process of switching C # read / write files from user mode to kernel mode?

# 补齐短板-开源IM项目OpenIM关于初始化/登录/好友接口文档介绍

Dialogue with the senior management of Chang'an Mazda, new products will be released in Q4, and space and intelligence will lead the Japanese system

Niuke programming problem -- dynamic programming of must brush 101 (a thorough understanding of dynamic programming)
随机推荐
[207] several possible causes of Apache crash
108. 简易聊天室11:实现客户端群聊
Lifeifei's team applied vit to the robot, increased the maximum speed of planning reasoning by 512 times, and also cued hekaiming's Mae
网页课程设计大作业——华山旅游网
QT 5.9.8 installation tutorial
知道这几个命令让你掌握Shell自带工具
Big talk Domain Driven Design -- presentation layer and others
Some instance methods of mono
GUI+SQLServer考试系统
day10每日3题(2):统计最大组的数目
IAR工程适配GD32芯片
Hyperf框架使用阿里云OSS上传失败
mha 切换(操作流程建议)
In a bad mood, I just write code like this
电路中缓存的几种形式
Niuke Xiaobai monthly race 50
【力扣刷题】单调栈:84. 柱状图中最大的矩形
Detailed explanation of cookies and sessions
用Attention和微调BERT进行自然语言推断-PyTorch
[机缘参悟-31]:鬼谷子-抵巇[xī]篇-危机是危险与机会并存