当前位置:网站首页>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.00Code :
#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);
}
边栏推荐
- retrofit
- Thread.sleep和TimeUnit.SECONDS.sleep的区别
- Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
- 天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库
- 一文了解微分段应用场景与实现机制
- 7-23 currency conversion (using array conversion)
- Understand the application scenario and implementation mechanism of differential segment
- 数学常数表 by q779
- 7-10 calculate salary
- puzzle(016.4)多米诺效应
猜你喜欢
随机推荐
Sword finger offer 28 Symmetric binary tree
7-18 finding the single root of polynomial by dichotomy
中国PETG市场预测及战略研究报告(2022版)
[clean up the extraordinary image of Disk C]
Etcd cluster permission management and account password usage
Eight sorts
npm install卡住与node-npy的各种奇怪报错
7-22 tortoise and rabbit race (result oriented)
Exercise 10-6 recursively find Fabonacci sequence
Doris学习笔记之数据表的创建
Exercise 8-2 calculate the sum and difference of two numbers
中国锂电池电解液行业市场专项调研报告(2022版)
String substitution
洛谷P5194 [USACO05DEC]Scales S 题解
Sendmail无法发送邮件及发送过慢解决
J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
超简单手机地图开发
编程语言:类型系统的本质
tonybot 人形机器人 查看端口并对应端口 0701
7-17 crawling worms (break exercise)









