如何找到最小和最大的数字? [英] How to find smallest and largest number?

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

问题描述

您好

编写程序时遇到问题请帮助我吗?


编写一个程序,找到最小的,最大的和N个正整数集合中的平均值。


谢谢,

Hello there
I have problem with writing a program could you please help me with that ?

Write a program that will find the smallest, largest and average of the values in a collection of N positive integer numbers.

Thanks,

推荐答案

忘记C为时刻。首先,你会如何找到整数集合中的最大整数?


通常,编程不是很难,而是你用于解决方案的方法。


如果你没有方法,那么你永远无法用代码解决程序。
Forget about C for the moment. First, how would you find the largest integer in a collection of integers?

Often it''s not the programming that hard, it''s the method you use for the solution.

If you have no method, then you can never solve the program with code.


是的这是我的问题我不知道如何获得该方法。


你能帮我吗?
Yes this is my problem I don''t know how to get the method .

Could you please help me with that ?


选择第一个数字作为最大数字。


把它写在一张纸上。


选择另一个号码。


如果它更大比纸上的数字,擦除纸上的数字,并用这个替换它。


选择另一个数字并重复,直到你选择了所有的数字。


最大的数字将出现在纸上。


现在你所要做的就是把这个方法翻译成C.

不要担心找到sma最少数量(虽然现在很明显)或平均值。只需让你的程序做这件事。


如果你遇到问题就发布你的代码。
Pick the first number as the largest number.

Write it on a piece of paper.

Pick another number.

If it''s bigger than the number on the paper, erase the number on the paper and replace it with this one.

Pick another number and repeat until you have picked all the numbers.

The largest number will be on the piece of paper.

All you have to do now is translate this method into C.

Don''t worry about finding the smallest number (though that is obvious now) or the average. Just get your program to do this one thing.

Post your code if you get stuck.


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

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