#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. zabbix触发器表达式详解

    Zabbix触发器的语法如下: {<server>:<key>.<function>(<parameter>)}<operator>< ...

  2. GraphLab GraphLab和MapReduce的区别

    https://turi.com/ GraphLab和MapReduce的区别 https://baike.baidu.com/item/GraphLab/16423125 2. GraphLab和M ...

  3. WordCount优化

    Github 地址:chaosrings/wcPro 1.PSP2.1表格 psp 2.1 psp阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 10 10 Estimate 估计这 ...

  4. vue - vue-cli脚手架安装和webpack-simple模板项目生成

    ue-cli 是一个官方发布 vue.js 项目脚手架,使用 vue-cli 可以快速创建 vue 项目. GitHub地址是:https://github.com/vuejs/vue-cli 一.安 ...

  5. GDB调试qemu源码纪录

    今天介绍下如何利用gdb调试qemu 1.首先获取qemu源码 获取地址:https://www.qemu.org/ 2.编译安装qemu 进入qemu目录 ./configure --enable- ...

  6. 正则验证ip

    用python爬获取这样一条数据: <td class="ip" id="ip"><p style="display: none;& ...

  7. 【服务器】如何在服务器发布网站?Sasa讲解

    一.网站发布过程 1.可以在淘宝.万维网上买服务器,然后客服提供一个服务器的远程ip链接,我们通过我们电脑的远程去链接这个远程服务器就可以对这个服务器进行控制了.. 2.将待发布网站的程序在本地保存, ...

  8. UIPageViewController基本使用

    UIPageViewController基本使用 @interface ViewController ()<UIPageViewControllerDelegate,UIPageViewCont ...

  9. python的时间差计算

    import time start = time.clock() #当中是你的程序 elapsed = (time.clock() - start) print("Time used:&qu ...

  10. tf.nn.embedding_lookup函数的用法

    关于np.random.RandomState.np.random.rand.np.random.random.np.random_sample参考https://blog.csdn.net/lanc ...