当前位置:网站首页>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)
- 攻防世界MISC练习区(gif 掀桌子 ext3 )
- Spot gold prices rose amid volatility, and the rise in U.S. prices is likely to become the key to the future
- Hackmyvm target series (2) -warrior
- Record once, modify password logic vulnerability actual combat
- Ucos-iii learning records (11) - task management
- Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
- flask实现强制登陆
- Detailed explanation of network foundation routing
- DVWA (5th week)
猜你喜欢
Database monitoring SQL execution
“Hello IC World”
Based on authorized access, cross host, and permission allocation under sqlserver
《统计学》第八版贾俊平第三章课后习题及答案总结
How to turn wechat applet into uniapp
Intranet information collection of Intranet penetration (2)
Data mining - a discussion on sample imbalance in classification problems
Low income from doing we media? 90% of people make mistakes in these three points
Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
Detailed explanation of network foundation
随机推荐
Mathematical modeling idea of 2022 central China Cup
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
Hcip -- MPLS experiment
函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
{1,2,3,2,5}查重问题
Realize applet payment function with applet cloud development (including source code)
Xray and burp linkage mining
How does SQLite count the data that meets another condition under the data that has been classified once
【指针】查找最大的字符串
Proceedingjoinpoint API use
Intranet information collection of Intranet penetration (4)
How to earn the first pot of gold in CSDN (we are all creators)
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
我的第一篇博客
记一次edu,SQL注入实战
2022华中杯数学建模思路
图书管理系统
The United States has repeatedly revealed that the yield of interest rate hiked treasury bonds continued to rise
Detailed explanation of network foundation routing
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案