当前位置:网站首页>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 95sample output :
average = 90.00
max = 95.00
min = 85.00The 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;
}
边栏推荐
- 2022-2028 global special starch industry research and trend analysis report
- Launpad | 基礎知識
- Regular expression (I)
- Exercise 9-5 address book sorting (20 points)
- Normal vector point cloud rotation
- Luogu deep foundation part 1 Introduction to language Chapter 4 loop structure programming (2022.02.14)
- Global and Chinese market of wheel hubs 2022-2028: Research Report on technology, participants, trends, market size and share
- C language pointer classic interview question - the first bullet
- 2022-2028 global elastic strain sensor industry research and trend analysis report
- Golang Modules
猜你喜欢

Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)

165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version

SQL replying to comments

2022-2028 global edible probiotic raw material industry research and trend analysis report

Qtreeview+ custom model implementation example

Hands on deep learning (34) -- sequence model

Hands on deep learning (33) -- style transfer

Machine learning -- neural network (IV): BP neural network

Normal vector point cloud rotation

C # use ffmpeg for audio transcoding
随机推荐
Global and Chinese PCB function test scale analysis and development prospect planning report Ⓑ 2022 ~ 2027
PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
Kubernetes CNI 插件之Fabric
Basic data types in golang
DR6018-CP01-wifi6-Qualcomm-IPQ6010-IPQ6018-FAMILY-2T2R-2.5G-ETH-port-CP01-802-11AX-MU-MIMO-OFDMA
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
JDBC and MySQL database
Hands on deep learning (43) -- machine translation and its data construction
QTreeView+自定义Model实现示例
C语言指针经典面试题——第一弹
C language pointer interview question - the second bullet
Explanation of closures in golang
Summary of small program performance optimization practice
PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
Flutter 小技巧之 ListView 和 PageView 的各種花式嵌套
The child container margin top acts on the parent container
Golang Modules
libmysqlclient. so. 20: cannot open shared object file: No such file or directory
libmysqlclient.so.20: cannot open shared object file: No such file or directory