什么叫“写一个循环(for或者while)读入五个浮点数?”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了什么叫“写一个循环(for或者while)读入五个浮点数?”相关的知识,希望对你有一定的参考价值。

【请写一段代码,该代码能够读入5 个浮点(float 类型)数,并能够得出这5 个浮点数
的平均值。
要求:
(1) 写一个循环(for或者while)读入5个浮点数;
(2) 计算出这5个浮点数的平均值;
(3) 在屏幕上打印出结果。
参考输入输出:
Please input 5 floating numbers
2.3 -1.2 4.56 7.8 9.99
Average is 4.690000】

ps:这是我的一个任务,先不管平均值,我怎么看不懂出题人的意思啊?用循环读入数?怎么读哇。。

循环读入就是利用数组与循环(如:for循环)来进行读入(赋值)
就是为了避免每次都用scanf中“%%%%%%%%%%%%%%%%%%”,&&&&&&&&&的麻烦,而采用的一种赋值手段
参考技术A #include <stdio.h>

int main()

float a,total;
int i;
total = 0.0;
printf("Please input 5 floating numbers\n");
// 循环读入5个浮点数
for(i=0; i<5; i++)

scanf("%f", &a);
total += a;

// 计算平均值并输出
total /= 5;
printf("Average is %.6f\n", total);

return 0;
参考技术B void main()

double a[5];
int i;
double sum=0.0;
printf("Please input 5 floating numbers");
for(i=0;i<5;i++)

scanf("%f",&a[i]);
sum+=a[i];

printf("%f",sum/5.0);
参考技术C 请问一下,是用c还是c++

什么叫拇指规则

什么叫做大拇指规则?我在经济学、管理学等等学科中都遇到过这个词,到底是什么意思呢?请求指点。谢了!

  大拇指规则 (RULE OF THUMB) 可以理解诚是一种试探法 (heuristics)

  试探法 (heuristics):The high-level, often imprecise rules of thumb and intuitive reasoning that experts use to solve problems.
  专家用于求解问题的高级的但常常是不确切的经验法则和直觉推理法。

  大拇指规则字面的理解应该是从经验、实践中总结得出的方法和规则什么的,不是经过科学实验得出的, 因为以前没有温度计,别人烧水什么的时候不知道到底有多热,所以呢就用大拇指浸一下,然后就可以知道,水已经很热了。还有一种说法,比较正常一点人性化一点,因为古代的时候大家都是用便于计量的单位来计量,比方说脚、手指,忘记掉以前哪个英国国王说,从我鼻子到我伸出的手指头就是一yard.

  大拇指法则=经验法则一种可用于许多情况的有用的原则,但并不是放诸四海皆准
  在英国普通法中, 有一条“大拇指规则”(rule of thumb), 意即只要用一根比大拇指小的棍子鞭打妻子,便不属虐待妻子行为。后经引申在管理学等其他知识领域上理解为经验和试探法.

  ----------------------------------------------
  附上大拇指规则的英文解释:
  "rule of thumb"
  by Mark Israel

  [This is a fast-access FAQ excerpt.]

  This term for "a simple principle having wide application but not
  intended to be strictly accurate" dates from 1692. A frequently
  repeated story is that "rule of thumb" comes from an old law
  regulating wife-beating: "if a stick were used, it should not be
  thicker than a man's thumb." Jesse Sheidlower writes at
  [...]

  [The URL that was given above is no longer valid. Jesse's
  article on "rule of thumb" is now at
  <http://www.randomhouse.com/wotd/index.pperl?date=19961108>.]

  "It seems that in 1782 a well-respected English judge named Francis
  Buller made a public statement that a man had the right to beat his
  wife as long as the stick was no thicker than his thumb. There was
  a public outcry, with satirical cartoons in newspapers, and the
  story still appeared in biographies of Buller written almost a
  century later. Several legal rulings and books in the late
  eighteenth and nineteenth centuries mention the practice as
  something some people believe is true. There are also earlier
  precedents for the supposed right of a man to beat his wife.

  "This 'rule' is probably not related to the phrase 'rule of
  thumb', however. For one thing, the phrase is [...] attested
  [earlier ...]. (Of course, it's possible that it was a well-known,
  but unrecorded, practice before Buller.) Another problem is that
  the phrase 'rule of thumb' is never found in connection with the
  beating practice until the 1970s. Finally, there is no semantic
  link [... from what was presumably a very specific distinction to
  the current sense 'rough guideline']. The precise origin of 'rule
  of thumb' is not certain, but it seems likely to refer to the thumb
  as a rough measuring device ('rule' meaning 'ruler' rather than
  'regulation'), which is a common practice. The linkage of the
  phrase to the wife-beating rule appears to be based on a
  misinterpretation of a 1976 National Organization of Women report,
  which mentioned the phrase and the practice but did not imply a
  connection. There is more information about this, with citations
  from relevant sources, at the Urban Legends Archive."

  Thumbs were used to measure *lots* of things (the first joint
  was roughly one inch long before we started growing bigger, and
  French pouce means both "inch" and "thumb"). The phrase may also
  come from ancient brewmasters' dipping their thumb in the brew to
  test the temperature of a batch; or from a guideline for tailors:
  "Twice around the thumb is once around the wrist..."

  For a definitive rule of thumb, see the paper "Thumb's rule
  tested: Visual angle of thumb's width is about 2 deg."
参考技术A “拇指规则”是指经济决策者对信息的处理方式不是按照理性预期的方式,把所有获得的信息都引入到决策模型中,他们往往遵循的是:只考虑重要信息,而忽略掉其他信息。否则信息成本无限高。

以上是关于什么叫“写一个循环(for或者while)读入五个浮点数?”的主要内容,如果未能解决你的问题,请参考以下文章

什么叫半栏图、通栏图?

什么叫“指定端口”?请说得通俗一点。

什么叫逃逸字符?

seo问题,啥叫正向匹配?啥叫逆向匹配?举例说明

什么叫计算机视觉?什么叫图像处理?二者的联系和区别是什么?

什么叫Access?作什么用的?它跟EXCEL有什么区别?