当前位置:网站首页>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
边栏推荐
- Sword finger offer 23 - print binary tree from top to bottom
- Internet Management (Information Collection)
- AQS details
- 《統計學》第八版賈俊平第七章知識點總結及課後習題答案
- Hackmyvm target series (2) -warrior
- What language should I learn from zero foundation. Suggestions
- JVM memory model concept
- Tencent map circle
- How to earn the first pot of gold in CSDN (we are all creators)
- Feature extraction and detection 14 plane object recognition
猜你喜欢

JDBC transactions, batch processing, and connection pooling (super detailed)

《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案

《统计学》第八版贾俊平第五章概率与概率分布

Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)

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

内网渗透之内网信息收集(四)

Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class

Realize applet payment function with applet cloud development (including source code)

Circular queue (C language)

Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
随机推荐
记一次api接口SQL注入实战
Only 40% of the articles are original? Here comes the modification method
JDBC transactions, batch processing, and connection pooling (super detailed)
Record an API interface SQL injection practice
关于交换a和b的值的四种方法
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class
数据库多表链接的查询方式
Load balancing ribbon of microservices
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
【指针】统计一字符串在另一个字符串中出现的次数
On the idea of vulnerability discovery
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
小程序web抓包-fiddler
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
MySQL interview questions (4)
The most popular colloquial system explains the base of numbers