当前位置:网站首页>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);
}
边栏推荐
猜你喜欢

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

Sword finger offer 28 Symmetric binary tree

Four data flows and cases of grpc

如何查询淘宝天猫的宝贝类目

Exercise 10-2 recursive factorial sum

愉悦资本新双币基金近40亿元完成首次关账

7-10 calculate salary

Exercise 6-1 classify and count the number of characters

Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not

Understand the application scenario and implementation mechanism of differential segment
随机推荐
Detailed explanation of four modes of distributed transaction (Seata)
Mysql多表查询 #子查询
7-18 finding the single root of polynomial by dichotomy
剑指 Offer 28. 对称的二叉树
亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
Selective sorting
Sendmail无法发送邮件及发送过慢解决
Exercise 10-3 recursive implementation of exponential functions
表单文本框的使用(一) 选择文本
Add ZABBIX calculation type itemcalculated items
Find specified characters
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
556. The next larger element III
Exercise 10-8 recursive implementation of sequential output of integers
Strategy, tactics (and OKR)
Special research report on the market of lithium battery electrolyte industry in China (2022 Edition)
Happy capital new dual currency fund nearly 4billion yuan completed its first account closing
tonybot 人形机器人 首次开机 0630
【7.3】146. LRU缓存机制