当前位置:网站首页>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;
}
边栏推荐
- Go context basic introduction
- Implementing expired localstorage cache with lazy deletion and scheduled deletion
- Trees and graphs (traversal)
- pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
- Problems encountered by scan, scanf and scanln in golang
- DR6018-CP01-wifi6-Qualcomm-IPQ6010-IPQ6018-FAMILY-2T2R-2.5G-ETH-port-CP01-802-11AX-MU-MIMO-OFDMA
- Report on the development trend and prospect trend of high purity zinc antimonide market in the world and China Ⓕ 2022 ~ 2027
- el-table单选并隐藏全选框
- C # use ffmpeg for audio transcoding
- libmysqlclient.so.20: cannot open shared object file: No such file or directory
猜你喜欢
Hands on deep learning (46) -- attention mechanism
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
MySQL foundation 02 - installing MySQL in non docker version
2022-2028 global special starch industry research and trend analysis report
2022-2028 global protein confectionery industry research and trend analysis report
165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
Hands on deep learning (35) -- text preprocessing (NLP)
2022-2028 global optical transparency industry research and trend analysis report
Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
随机推荐
智慧路灯杆水库区安全监测应用
Four common methods of copying object attributes (summarize the highest efficiency)
Go context basic introduction
On Multus CNI
MySQL transaction mvcc principle
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
Hands on deep learning (40) -- short and long term memory network (LSTM)
Fabric of kubernetes CNI plug-in
Golang type comparison
Investment analysis and future production and marketing demand forecast report of China's paper industry Ⓥ 2022 ~ 2028
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
Regular expression (I)
Hands on deep learning (35) -- text preprocessing (NLP)
Analysis report on the production and marketing demand and investment forecast of tellurium dioxide in the world and China Ⓣ 2022 ~ 2027
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
Multilingual Wikipedia website source code development part II
Basic data types in golang
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
QTreeView+自定义Model实现示例