#include<stdio.h>
int main() {
// 声明与初始化
int n, count=, s=, age=; // 输入学生人数
scanf("%d", &n); // 循环读入 加和
while(count<=n) {
scanf("%d",&age);
s+=age;
count++;
} // 计算平均年龄输出
printf("%.2f\n",1.0*s/n);
return ;
}
/*
pkuic_1716.c
计算概论(A)/基础编程练习2(8题)/1:求平均年龄
http://pkuic.openjudge.cn/base2/1/
1:求平均年龄
查看 提交 统计 提问
总时间限制: 1000ms 内存限制: 65536kB
描述
班上有学生若干名,给出每名学生的年龄(整数),求班上所有学生的平均年龄,保留到小数点后两位。
输入
第一行有一个整数n(1<= n <= 100),表示学生的人数。其后n行每行有1个整数,表示每个学生的年龄,取值为15到25。
输出
输出一行,该行包含一个浮点数,为要求的平均年龄,保留到小数点后两位。
样例输入
2
18
17
样例输出
17.50
提示
要输出浮点数、双精度数小数点后2位数字,可以用下面这种形式:
printf("%.2f", num);
来源
2005~2006医学部计算概论期末考试
*/

计算概论(A)/基础编程练习2(8题)/1:求平均年龄的更多相关文章

  1. 计算概论(A)/基础编程练习1(8题)/4:求一元二次方程的根

    #include<stdio.h> #include<math.h> int main() { // 待解方程数目 int n; scanf("%d", & ...

  2. 计算概论(A)/基础编程练习2(8题)/8:1的个数

    #include<stdio.h> int main() { ; // 存储测试数据的二进制形式中1的个数 int bian[N]; // 输入十进制整数N 表示N行测试数据 scanf( ...

  3. 计算概论(A)/基础编程练习2(8题)/7:整数的个数

    #include<stdio.h> int main() { ] = {}; // 输入k个正整数 scanf("%d",&k); // 循环读入和进行算术 w ...

  4. 计算概论(A)/基础编程练习2(8题)/6:数组逆序重放

    #include<stdio.h> int main() { // 输入n个整数 ; scanf("%d", &n); // 循环读入元素 while(scan ...

  5. 计算概论(A)/基础编程练习2(8题)/5:点和正方形的关系

    #include<stdio.h> #include<math.h> int main() { // 输入坐标 float x, y; while(scanf("%f ...

  6. 计算概论(A)/基础编程练习1(8题)/2:苹果和虫子

    #include<stdio.h> #include<math.h> int main() { /* n个苹果 每x小时能吃掉一个苹果 经过y小时 */ float n, x, ...

  7. 计算概论(A)/基础编程练习1(8题)/1:大象喝水

    #include<stdio.h> int main() { ; // n < 100 scanf("%d", &n); // 循环遍历判断 再进行平方和 ...

  8. 计算概论(A)/基础编程练习2(8题)/4:骑车与走路

    #include<stdio.h> int main() { // 待处理的数据数量n ; scanf("%d", &n); float meters[n]; ...

  9. 计算概论(A)/基础编程练习2(8题)/3:计算三角形面积

    #include<stdio.h> #include<math.h> int main() { // 声明三角形的三个顶点坐标和面积 float x1, y1, x2, y2, ...

随机推荐

  1. mysqladmin 命令详解

    mysqladmin是一个执行管理操作的客户端程序.它可以用来检查服务器的配置和当前状态.创建和删除数据库等. mysqladmin 工具的使用格式: mysqladmin [option] comm ...

  2. poj2406 Power Strings 【KMP】

    Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc&quo ...

  3. ubuntu16.04下安装artoolkit5

    目前对AR技术的常见理解就是CV(Computer Vision)+CG(Computer Graphic).CV的方法很多,简单些比如FREAK+ICP(ARToolKit中的NFT),复杂些就是S ...

  4. 力推:无限制下载神器aria2

    百度网盘是一个非常方便的存储以及寻找资源的好帮手,但是百度为了挣钱把非会员的下载网速一再限制(无力吐槽),还还好一直使用油猴插件加idm下载神器来下载百度云文件.奈何idm对bt种子文件不支持下载,终 ...

  5. Why is long2ip conversion important?

    Frequently Asked Questions about Convert long to IP address https://long2ip.com/faq/ What is long2ip ...

  6. 前端开发组件化设计vue,react,angular原则漫谈

    前端开发组件化设计vue,react,angular原则漫谈 https://www.toutiao.com/a6346443500179505410/?tt_from=weixin&utm_ ...

  7. ElasticSearch报 EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@c0efba

    ElasticSearch报以下错误的解决办法: "type": "es_rejected_execution_exception", "reason ...

  8. 新建虚拟机_XP系统(一)

    准备工作:(1)安装VMware (2)下载系统镜像文件 1.新建虚拟机 2.下一步,选择“稍后安装操作系统” 3.选择操作系统类型和版本 4.设置虚拟机名称和安装位置 (安装路径空间要足够大) 5. ...

  9. Alisha’s Party---hdu5437(模拟+优先队列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5437 题意:公主有k个朋友来参加她的生日party,每个人都会带价值为v[i]的礼物过来,在所有人到齐 ...

  10. hive-site.xml配置

    <?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-s ...