int main()

{

int number ;

int sum = 0;

int count = 0;

    do
{
scanf(“%d”, &number );
if( number != -1)
{
sum += number;
count ++;
}
} while ( number != -1 ); printf("%f \n", 1.0*sum/count); return 0;
}
可变

变量

sum  累加和
number 数
count 计数

C语言 算平均数的更多相关文章

  1. 用python语言算π值并且带有进度条

    用python算圆周率π 1.准备第三方库pip 打开cmd 输入代码:pip install requests ,随后就会成功 因为小编已经安装好了,所以就不把图截出来了 2.利用马青公式求π    ...

  2. C语言 · 算年龄

    算年龄 英国数学家德摩根出生于19世纪初叶(即18xx年). 他年少时便很有才华.一次有人问他的年龄,他回答说: “到了x的平方那年,我刚好是x岁”. 请你计算一下,德摩根到底出生在哪一年. 题中的年 ...

  3. C语言浮点数除法可以精确到多少位小数

    double型的两个数相除,得到的浮点数能精确到多少位呢..用我家电脑做了个实验,编译器是Code::Blocks 13.12. 然后用电脑自带的计算器算的结果和C语言算的结果比较如图. 第一例里a= ...

  4. C语言入门-循环

    一.循环 输入一个数字,输出该数字有几位 #include <stdio.h> int main() { int x; int n = 0; scanf("%d" , ...

  5. SqlServer 函数 大全

    sql server使用convert来取得datetime日期数据 sql server使用convert来取得datetime日期数据,以下实例包含各种日期格式的转换 语句及查询结果: Selec ...

  6. sql Server 的基本函数

    --聚合函数 use pubs go select avg(distinct搜索 price) --算平均数 from titles where type='business' go use pubs ...

  7. 转载:Hadoop权威指南学习笔记

    转自:http://pieux.github.io/blog/2013-05-08-learn-hadoop-the-definitive-guide.html 1 前言 Hadoop的内部工作机制: ...

  8. MS-SQL Server字符串处理函数大全

    MS-SQL Server字符串处理函数大全   select语句中只能使用sql函数对字段进行操作(链接sql server), select 字段1 from 表1 where 字段1.Index ...

  9. 常用SQL代码段

    代码使用时须测试. --聚合函数 use pubs go select avg(distinct price) --算平均数 from titles where type='business' go ...

随机推荐

  1. Visual Studio Find All no results.

    重装WDK什么的有时候有bug....写下面注册表修复 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Wow6432Node\CLSI ...

  2. kubenetes dns

    E0228 07:32:28.912833       1 reflector.go:201] k8s.io/dns/pkg/dns/dns.go:147: Failed to list *v1.En ...

  3. What is _MainTex_ST ?

    [What is _MainTex_ST ?] 在Unity自带的Unlit/Texture中,有引用到float4 _MainTex_ST,如下: // Unlit shader. Simplest ...

  4. cdoj1088-王之迷宫 (三维迷宫最短路径)【BFS】

    http://acm.uestc.edu.cn/#/problem/show/1088 王之迷宫 Time Limit: 3000/1000MS (Java/Others)     Memory Li ...

  5. 69. Sqrt(x) (Divide-and-Conquer)

    Implement int sqrt(int x). Compute and return the square root of x. 注意: 计算平方的时候可能会溢出,所以mid要定义为long 另 ...

  6. 最长的相同节点值路径 · Longest Univalue Path

    [抄题]: Given a binary tree, find the length of the longest path where each node in the path has the s ...

  7. 单例模式的N种写法

    单例模式算是设计模式中最容易理解,也是最容易手写代码的模式了吧.但是其中的坑却不少,所以也常作为面试题来考.本文主要对几种单例写法的整理,并分析其优缺点.很多都是一些老生常谈的问题,但如果你不知道如何 ...

  8. csv乱码

    可能:iconv转码导致,本身已经是GBK,又进行了GBK转码

  9. 【转】The most comprehensive Data Science learning plan for 2017

    I joined Analytics Vidhya as an intern last summer. I had no clue what was in store for me. I had be ...

  10. requests+正则表达式 爬取 妹子图

    做了一个爬取妹子图某张索引页面的爬虫,主要用request和正则表达式. 感谢 崔庆才大神的 爬虫教学视频 和 gitbook: B站:https://www.bilibili.com/video/a ...