如何分离两种输出并对它们求平均值? [英] How to separate two kinds of outputs and average them?
问题描述
大家好 - 我是编程和学习的新手。我已经制作了一个程序,允许用户将温度从F转换为C,C转换为F,这是用户想要的次数。大部分程序都已完成,但我仍然坚持这一部分:
问题:我似乎无法弄清楚如何分离华氏度和摄氏度输出,以及平均他们每个人分开。华氏温度平均值和摄氏度平均值。
这是代码:
Hi all - I''m new to programming and still learning. I''ve made a program that lets the user convert temperature from F to C and C to F, as many times as the user wants. Most of the program is pretty much done but I am stuck on this part:
Question: I can''t seem to figure out how to separate the fahrenheit and centigrade outputs, and averaging each of them separately. A fahrenheit average and a centigrade average.
Here is the code:
推荐答案
问题:我似乎无法弄清楚如何分离华氏度和摄氏度输出,并分别对每个输出求平均值。华氏温度平均值和摄氏度平均值。
Question: I can''t seem to figure out how to separate the fahrenheit and centigrade outputs, and averaging each of them separately. A fahrenheit average and a centigrade average.
好吧,我不确定我是否理解你所说的平均每一个。但是,你的缩进风格是缺乏的。我不得不重新启动你的代码,直到我意识到你已经将开放式括号''''和一些代码放在同一行之后,我仍然无法阅读它。它没有多大意义,并且很难快速理解。我建议像这样设置你的块:
Ok, I''m not sure if I understand what you are saying by averaging each seperatly. However, your indention style is lacking. I had to reindent your code and still I couldn''t read it until I realised you had put the open brace ''{'' and some code right after it on the same line. It didn''t make much sense and makes it harder to understand quickly. I would suggest setting up your blocks like this:
好吧,我不确定我是否理解你所说的平均每一个。但是,你的缩进风格是缺乏的。我不得不重新启动你的代码,直到我意识到你已经将开放式括号''''和一些代码放在同一行之后,我仍然无法阅读它。它没有多大意义,并且很难快速理解。我建议像这样设置你的块:
Ok, I''m not sure if I understand what you are saying by averaging each seperatly. However, your indention style is lacking. I had to reindent your code and still I couldn''t read it until I realised you had put the open brace ''{'' and some code right after it on the same line. It didn''t make much sense and makes it harder to understand quickly. I would suggest setting up your blocks like this:
好吧,为了找到一个平均值,你需要一笔金额和总数。由于您需要2个平均值,因此需要2个总和和2个总计。你可以有6个变量,定义如下:
Well, in order to find an average, you need to have a sum and a total number. Since you need 2 averages, you will need 2 sums and 2 totals. You can have 6 variables, defined as follows:
这篇关于如何分离两种输出并对它们求平均值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!