当前位置:网站首页>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");
}
}
边栏推荐
- 最小二乘系统辨识课 中篇:递归最小二乘
- C语言所有知识点小结
- Structure the graduation project of actual combat camp
- Experience in hierarchical debugging of boards and cards
- 若依微服务特殊字符串被过滤的解决办法
- IAR工程适配GD32芯片
- JS教程之使用 ElectronJS、VueJS、SQLite 和 Sequelize ORM 从 A 到 Z 创建多对多 CRUD 应用程序
- 知道这几个命令让你掌握Shell自带工具
- 基於Kubebuilder開發Operator(入門使用)
- This year, the AI score of college entrance examination English is 134. The research of Fudan Wuda alumni is interesting
猜你喜欢

Arduino UNO + DS1302简单获取时间并串口打印

Oilfield exploration problems

# 补齐短板-开源IM项目OpenIM关于初始化/登录/好友接口文档介绍
Scala Foundation (2): variables et types de données

知道这几个命令让你掌握Shell自带工具

Niuke programming problem -- dynamic programming of must brush 101 (a thorough understanding of dynamic programming)

MS|谢黎炜组发现混合益生菌制剂及其代谢产物可缓解结肠炎

Stm32h7b0 replaces the h750 program, causing the MCU to hang up and unable to burn the program

Cuckoo filter for Chang'an chain transaction

Gui+sqlserver examination system
随机推荐
This year, the AI score of college entrance examination English is 134. The research of Fudan Wuda alumni is interesting
day10每日3题(3):数组中的字符串匹配
Make up the weakness - Open Source im project openim about initialization / login / friend interface document introduction
proxy
1-12vmware adds SSH function
MS|谢黎炜组发现混合益生菌制剂及其代谢产物可缓解结肠炎
国内首款开源 MySQL HTAP 数据库即将发布,三大看点提前告知
Kept to implement redis autofailover (redisha) 1
JS教程之Electron.js设计强大的多平台桌面应用程序的好工具
Mono 的一些实例方法
What is the process of switching C # read / write files from user mode to kernel mode?
当一个程序员一天被打扰 10 次,后果很惊人!
【力扣刷题】11.盛最多水的容器//42.接雨水
R329 (maix-ii-a (M2A) data summary
Solution for filtering by special string of microservice
Vibrating liquid quantity detecting device
GUI+SQLServer考试系统
proxy
Scala 基礎 (二):變量和數據類型
若依打包如何分离jar包和资源文件?