当前位置:网站首页>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;
}
边栏推荐
- MySQL transaction mvcc principle
- Four common methods of copying object attributes (summarize the highest efficiency)
- Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
- Lauchpad X | 模式
- Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
- How can Huawei online match improve the success rate of player matching
- MySQL develops small mall management system
- Dynamic analysis and development prospect prediction report of high purity manganese dioxide in the world and China Ⓡ 2022 ~ 2027
- PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f
- Global and Chinese markets of thrombography hemostasis analyzer (TEG) 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Four common methods of copying object attributes (summarize the highest efficiency)
C语言指针面试题——第二弹
Hands on deep learning (34) -- sequence model
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
Hands on deep learning (38) -- realize RNN from scratch
Summary of reasons for web side automation test failure
How can Huawei online match improve the success rate of player matching
2022-2028 global probiotics industry research and trend analysis report
QTreeView+自定义Model实现示例
Normal vector point cloud rotation
随机推荐
2022-2028 global special starch industry research and trend analysis report
Flutter 小技巧之 ListView 和 PageView 的各種花式嵌套
Four common methods of copying object attributes (summarize the highest efficiency)
libmysqlclient.so.20: cannot open shared object file: No such file or directory
El Table Radio select and hide the select all box
Hands on deep learning (36) -- language model and data set
Hands on deep learning (37) -- cyclic neural network
C语言指针面试题——第二弹
智慧路灯杆水库区安全监测应用
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
How does idea withdraw code from remote push
Write a jison parser from scratch (4/10): detailed explanation of the syntax format of the jison parser generator
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
What are the advantages of automation?
How to display √ 2 on the command line terminal ̅? This is actually a blog's Unicode test article
什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
2022-2028 global probiotics industry research and trend analysis report
On Multus CNI
Kotlin:集合使用