当前位置:网站首页>Exercise 8-10 output student grades (20 points)
Exercise 8-10 output student grades (20 points)
2022-07-04 09:47:00 【skeet follower】
This question requires the preparation of procedures , According to the input student's score , Count and output the average score of students 、 Top and bottom . Dynamic memory allocation is recommended for .
Input format :
Enter the first line to first give a positive integer N, Number of students . The next line shows N Results of students , Numbers are separated by spaces .
Output format :
Output in the following format :
average = Average score
max = Top grade
min = Minimum score
Keep two decimal places for results .
sample input :
3
85 90 95
sample output :
average = 90.00
max = 95.00
min = 85.00
The code is as follows :
#include<stdio.h>
#include<stdlib.h>
int main()
{
double max=0,min=0,sum=0;
double average=0;
int n,i;
scanf("%d",&n);
double a[n];
//double *ave= (double *)malloc( n* sizeof(double)); Dynamic memory allocation application
for(i=0;i<n;i++){
scanf("%lf",&a[i]);
}
max=min=a[0];
for(i=0;i<n;i++){
sum+=a[i];
if(a[i]>max){
max=a[i];
}
if(a[i]<min){
min=a[i];
}
}
printf("average = %.2f\n",sum/n);
printf("max = %.2f\n",max);
printf("min = %.2f\n",min);
//free(0); Release space
return 0;
}
边栏推荐
- MATLAB小技巧(25)竞争神经网络与SOM神经网络
- 回复评论的sql
- Four common methods of copying object attributes (summarize the highest efficiency)
- C language pointer interview question - the second bullet
- System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
- Golang Modules
- MySQL develops small mall management system
- The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
- Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
- 法向量点云旋转
猜你喜欢
Normal vector point cloud rotation
回复评论的sql
How can people not love the amazing design of XXL job
2022-2028 global visual quality analyzer industry research and trend analysis report
2022-2028 research and trend analysis report on the global edible essence industry
Write a mobile date selector component by yourself
2022-2028 global edible probiotic raw material industry research and trend analysis report
Hands on deep learning (39) -- gating cycle unit Gru
Fabric of kubernetes CNI plug-in
libmysqlclient. so. 20: cannot open shared object file: No such file or directory
随机推荐
Write a jison parser from scratch (3/10): a good beginning is half the success -- "politics" (Aristotle)
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
libmysqlclient.so.20: cannot open shared object file: No such file or directory
Write a jison parser from scratch (6/10): parse, not define syntax
Hands on deep learning (38) -- realize RNN from scratch
Golang Modules
2022-2028 global protein confectionery industry research and trend analysis report
Explanation of for loop in golang
libmysqlclient. so. 20: cannot open shared object file: No such file or directory
[on February 11, 2022, the latest and most fully available script library collection of the whole network, a total of 23]
2022-2028 global probiotics industry research and trend analysis report
Web端自动化测试失败原因汇总
Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
xxl-job惊艳的设计,怎能叫人不爱
H5 audio tag custom style modification and adding playback control events
MySQL develops small mall management system
Logstack configuration details -- elasticstack (elk) work notes 020
Modules golang
How to batch change file extensions in win10