如何查找和处理最大和最小数字? [英] How to find and deal with maximum and minimum numbers?

查看:81
本文介绍了如何查找和处理最大和最小数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C初学者。

我想写一个C.

伪代码是这样的:


用户输入一些数字(使用-1结束)

编译器查找并删除最大和最小数字

然后平均剩余数字

最后打印结果


提前致谢!!!

Hi, I''m a C beginner.
I want to write a C.
The pseudocodes are like this:

User enters some numbers (use -1 to end)
The compiler find and delete the maximum and minimum numbers
Then average remained numbers
Finally print the result

Thanks in advance!!!

推荐答案

zj ****** @ 163.com 写道:

我是C初学者。

我想写一个C.

伪代码是这样的:


用户输入一些数字(使用-1结束)

编译器查找并删除最大和最小数字

然后平均剩余数字

最后打印结果


提前致谢!!!
Hi, I''m a C beginner.
I want to write a C.
The pseudocodes are like this:

User enters some numbers (use -1 to end)
The compiler find and delete the maximum and minimum numbers
Then average remained numbers
Finally print the result

Thanks in advance!!!



做你自己的作业。


如果你不自己动手做作业就可以教你了吗? >
你将不会学到任何东西

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs .virginia.edu / ~lcc-win32


zj * *****@163.com 写道:

我是C初学者。

我想要写一个C.

伪代码是这样的:


用户输入一些数字(用-1结束)

编译器查找并删除最大和最小数字

然后平均剩余数字

最后打印结果


提前致谢! !
Hi, I''m a C beginner.
I want to write a C.
The pseudocodes are like this:

User enters some numbers (use -1 to end)
The compiler find and delete the maximum and minimum numbers
Then average remained numbers
Finally print the result

Thanks in advance!!!



对我来说看起来不像伪代码,就像(家庭作业)任务一样。也许

以下内容有助于您入门:


读取数量

counter = 1

max = min = sum = number


循环

读数

counter ++

如果数字最大

max =数字

否则如果数字< min

min =数字

总和+ =数字

重复而数字不是-1


总和 - =(最小值+最大值)

计数器 - = 2 / *表示最小值最大值不再存在* /

结果=总和/计数器
打印结果


再见,Jojo

Doesn''t look like pseudocode to me, mor like a (homework) task. Maybe the
following helps to get you started:

read number
counter=1
max = min = sum = number

loop
read number
counter++
if number max
max = number
else if number < min
min = number
sum += number
repeat while number not -1

sum -= (min+max)
counter -=2 /* to account for min amd max not being in anymore */
result = sum/counter
print result

Bye, Jojo


Joachim Schmitz说:
Joachim Schmitz said:
zj******@163.com 写道:

>我是C初学者。
我想写一个C.
伪代码是这样的:

用户输入一些数字(使用-1结束)
编译器查找并删除最大和最小数字
然后平均剩余数字
最后打印结果

提前致谢!! !
>Hi, I''m a C beginner.
I want to write a C.
The pseudocodes are like this:

User enters some numbers (use -1 to end)
The compiler find and delete the maximum and minimum numbers
Then average remained numbers
Finally print the result

Thanks in advance!!!



对我来说看起来不像伪代码,就像(家庭作业)任务一样。也许

以下内容有助于您入门:


读取数量

counter = 1

max = min = sum = number


循环

读数

counter ++

如果数字最大

max =数字

否则如果数字< min

min =数字

总和+ =数字

重复而数字不是-1


总和 - =(最小值+最大值)

计数器 - = 2 / *表示最小值最大值不再存在* /

结果=总和/计数器
打印结果


Doesn''t look like pseudocode to me, mor like a (homework) task. Maybe the
following helps to get you started:

read number
counter=1
max = min = sum = number

loop
read number
counter++
if number max
max = number
else if number < min
min = number
sum += number
repeat while number not -1

sum -= (min+max)
counter -=2 /* to account for min amd max not being in anymore */
result = sum/counter
print result



对不起,我不认为这回答了OP的问题。他想要

*编译器*来查找和删除最大和最小数字。


Tricky - 但我认为显而易见的方法是编写代码生成器

包含受预处理器保护的答案的硬编码列表

定义(或者,如果不允许,则使用if(0)然后打开为

你可以找到许多优化),然后向编译器发出外壳。


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

Sorry, but I don''t think that answers the OP''s question. He wants the
*compiler* to find and delete the maximum and minimum numbers.

Tricky - but I suppose the obvious approach is to write a code generator
containing a hard-coded list of the answers protected by preprocessor
definitions (or, if that''s not allowed, use if(0) and then switch on as
many optimisations as you can find), and then shell out to the compiler.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


这篇关于如何查找和处理最大和最小数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆