当前位置:网站首页>Output student grades
Output student grades
2022-07-03 14:33:00 【Study hard 867】
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
Code :
#include <stdio.h>
int main(){
int N;
scanf("%d",&N);
double a[N];
double average,max,min,sum=0;
int i,j;
for(i=0;i<N;i++){
scanf("%lf",&a[i]);
sum=sum+a[i];
}
average=sum/N;
max=a[0];
for(i=0;i<N-1;i++){
if(max<a[i+1])max=a[i+1];
}
min=a[0];
for(i=0;i<N-1;i++){
if(min>a[i+1])min=a[i+1];
}
printf("average = %.2lf\nmax = %.2lf\nmin = %.2lf",average,max,min);
}
边栏推荐
- The mail function of LNMP environment cannot send mail
- Doris学习笔记之数据表的创建
- J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
- 7-22 tortoise and rabbit race (result oriented)
- 洛谷P3065 [USACO12DEC]First! G 题解
- 556. 下一个更大元素 III
- Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
- Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- 中国锂电池电解液行业市场专项调研报告(2022版)
猜你喜欢
Creation of data table of Doris' learning notes
retrofit
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
x86汇编语言-从实模式到保护模式 笔记
Exercise 10-6 recursively find Fabonacci sequence
protobuf与grpc
Sword finger offer 28 Symmetric binary tree
论文分享:Generating Playful Palettes from Images
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Exercise 8-8 moving letters
随机推荐
Recent learning summary
Detailed explanation of four modes of distributed transaction (Seata)
7-17 crawling worms (break exercise)
7-8 overspeed judgment
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
Showmebug entered Tencent conference, opening the era of professional technical interview
中国PETG市场预测及战略研究报告(2022版)
Zabbix添加Calculated items后保存页面成空白
洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解
PCB中常用快捷键
7-23 currency conversion (using array conversion)
7-6 mixed type data format input
Find specified characters
J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
7-19 check denomination (solve binary linear equation)
C library function - qsort()
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
The mail function of LNMP environment cannot send mail
Exercise 9-3 plane vector addition
MongoDB索引