当前位置:网站首页>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);
}
边栏推荐
- NPM install is stuck with various strange errors of node NPY
- Etcd cluster permission management and account password usage
- MySQL multi table query subquery
- 中国PETG市场预测及战略研究报告(2022版)
- fpga阻塞赋值和非阻塞赋值
- SSH访问控制,多次失败登录即封掉IP,防止暴力破解
- tonybot 人形机器人 首次开机 0630
- 提高效率 Or 增加成本,开发人员应如何理解结对编程?
- Doris学习笔记之数据表的创建
- Puzzle (016.4) domino effect
猜你喜欢
Tonybot Humanoïde Robot Infrared Remote play 0630
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
ConstraintLayout 的使用
愉悦资本新双币基金近40亿元完成首次关账
pyQt界面制作(登录+跳转页面)
tonybot 人形機器人 紅外遙控玩法 0630
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
随机推荐
一文了解微分段应用场景与实现机制
别再问自己适不适合做软件测试了
puzzle(016.4)多米诺效应
tonybot 人形机器人 首次开机 0630
数学常数表 by q779
Niuke: crossing the river
Add ZABBIX calculation type itemcalculated items
Puzzle (016.3) is inextricably linked
556. 下一个更大元素 III
Selective sorting
Exercise 8-2 calculate the sum and difference of two numbers
7-14 sum integer segments (C language)
Sendmail无法发送邮件及发送过慢解决
Zabbix添加Calculated items后保存页面成空白
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
7-18 finding the single root of polynomial by dichotomy
Exercise 10-2 recursive factorial sum
Common commands for getting started with mongodb database
retrofit