当前位置:网站首页>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;
}
边栏推荐
- Trees and graphs (traversal)
- 2022-2028 global strain gauge pressure sensor industry research and trend analysis report
- Web端自动化测试失败原因汇总
- Golang defer
- 2022-2028 research and trend analysis report on the global edible essence industry
- Machine learning -- neural network (IV): BP neural network
- Get the source code in the mask with the help of shims
- 直方图均衡化
- 2022-2028 global edible probiotic raw material industry research and trend analysis report
- 2022-2028 global gasket plate heat exchanger industry research and trend analysis report
猜你喜欢
Ultimate bug finding method - two points
2022-2028 global edible probiotic raw material industry research and trend analysis report
Hands on deep learning (39) -- gating cycle unit Gru
What are the advantages of automation?
Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
MATLAB小技巧(25)竞争神经网络与SOM神经网络
QTreeView+自定义Model实现示例
自动化的优点有哪些?
Normal vector point cloud rotation
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
随机推荐
SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
直方图均衡化
Implementing expired localstorage cache with lazy deletion and scheduled deletion
Web端自动化测试失败原因汇总
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
Modules golang
How can people not love the amazing design of XXL job
Machine learning -- neural network (IV): BP neural network
C language pointer classic interview question - the first bullet
Hands on deep learning (32) -- fully connected convolutional neural network FCN
2022-2028 global seeder industry research and trend analysis report
7-17 crawling worms (15 points)
Write a jison parser from scratch (2/10): learn the correct posture of the parser generator parser generator
Hands on deep learning (36) -- language model and data set
Advanced technology management - how to design and follow up the performance of students at different levels
mmclassification 标注文件生成
2022-2028 global intelligent interactive tablet industry research and trend analysis report
xxl-job惊艳的设计,怎能叫人不爱
Lauchpad X | 模式
JDBC and MySQL database