当前位置:网站首页>Pointeurs: maximum, minimum et moyenne
Pointeurs: maximum, minimum et moyenne
2022-07-06 14:34:00 【Lumière】
Exigences
Écrire le programme,Saisissez un tableau d'entiers unidimensionnels,Valeur maximale de sortie、Minimum et moyenne.(Avec un pointeur)
Code
#include<stdio.h>
/* * Cette fonction est utilisée pour saisir un tableau d'entiers unidimensionnels,Les données saisies sont stockées dans des paramètres formelsaDans le tableau * Données saisies pour0Comme signe de fin,0Ne pas enregistrer dans le tableau et ne pas compter dans le total des données d'entrée * La valeur de retour est le nombre de données d'entrée */
int input(int a[])
{
int n=0;
int b = 0;
do
{
scanf("%d",&b);
if(b == 0)
break;
else
{
a[n] = b;
n++;
}
}
while(b != 0);
return n;
}
/* * Cette fonction est utilisée pour calculer le tableau des paramètres formelsaMax in、Minimum、Moyenne * Max.、Minimum、La moyenne passe par les variables du pointeur de paramètrepmax、pmin、pavgPour passer * nEst un tableau de paramètres formelsaNombre de données dans */
void fun(int a[],int *pmax,int *pmin,int *pavg,int n)
{
int i,j,k=0;
*pmax = a[0];
*pmin = a[0];
for(i=1;i<n;i++)
{
if(*pmin > a[i])
{
*pmin = a[i];
}
if(*pmax < a[i])
{
*pmax = a[i];
}
k = k + a[i];
*pavg = (k + a[0])/n;
}
}
mainFonctions
int main()
{
int a[200],n,max,min,avg;
n=input(a);
fun(a,&max,&min,&avg,n);
printf("Max.%d,Min.%d,La moyenne est%d\n",max,min,avg);
return 0;
}
Tests
Test Input
1 3 5 7 0
Produits
Max.7,Min.1,La moyenne est4
边栏推荐
- 《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
- Intranet information collection of Intranet penetration (3)
- 《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
- XSS之冷门事件
- Lintcode logo queries the two nearest saplings
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
- 《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
- Which is more advantageous in short-term or long-term spot gold investment?
- Hackmyvm target series (1) -webmaster
猜你喜欢

servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。

Build domain environment (win)

数据库多表链接的查询方式

Ucos-iii learning records (11) - task management

1.支付系统

网络基础详解
![New version of postman flows [introductory teaching chapter 01 send request]](/img/0f/a41a39093a1170cc3f62075fd76182.jpg)
New version of postman flows [introductory teaching chapter 01 send request]

记一次api接口SQL注入实战

Record an API interface SQL injection practice

Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
随机推荐
Proceedingjoinpoint API use
我的第一篇博客
Intel oneapi - opening a new era of heterogeneity
SystemVerilog discusses loop loop structure and built-in loop variable I
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
小程序web抓包-fiddler
Markdown font color editing teaching
【指针】求字符串的长度
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Hcip -- MPLS experiment
Interpretation of iterator related "itertools" module usage
Low income from doing we media? 90% of people make mistakes in these three points
. Net6: develop modern 3D industrial software based on WPF (2)
[err] 1055 - expression 1 of order by clause is not in group by clause MySQL
Solutions to common problems in database development such as MySQL
Xray and burp linkage mining
1.支付系统
How does SQLite count the data that meets another condition under the data that has been classified once
Database monitoring SQL execution
四元数---基本概念(转载)