帮助我的c ++示例 [英] help with my c++ example

查看:56
本文介绍了帮助我的c ++示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


我必须编写以下程序。


1.用户输入一个数字(例如:5)

2.然后(因为他进入了5)他进入5次,每次都不同,

3位数(例如:134,256,425,253,275 )

3.然后我必须找到他输入的最低值并将其打印出来


我不知道我该怎么做,因为如果用户输入一个mubers

100所以他将输入100个不同的3位数字。你必须

声明每个数字(例如:int a = 1; ... )这意味着我需要申报100美元!但那不可能,如果用户确定他要输入1000000个不同的3位数字怎么办?


帮助我,请

Hi to all!

I have to write the following program.

1.User inputs a number (example: 5)
2.Then (because he entered 5) he enters 5 times, each time different,
3-placed number (example: 134, 256, 425, 253, 275)
3.then I have to find the lowest of those he entered and print it out

I have no idea how do I do that, because If the user enters a mubers
100 so he will input 100 different 3-placed numbers.you have to
declare each number (example: int a = 1;...)so that would mean that i
need to declare 100ints!! but thats impossible, what if the user
decides he is going to input 1000000 different 3-placed numbers?

help me out, please

推荐答案



" vbmax" <峰; bs ***** @ yahoo.com>在留言中写道

新闻:4d ************************** @ posting.google.c om ...

"vbmax" <bs*****@yahoo.com> wrote in message
news:4d**************************@posting.google.c om...
大家好!

我必须编写以下程序。

1.用户输入一个数字(例如:5)
2.然后(因为他进入5)他进入5次,每次不同,
3位数(例如:134,256,425,253,275)
3.然后我必须找到他输入的最低的并打印出来

我不知道我该怎么做,因为如果用户输入一个mubers
100所以他会输入100个不同的3-placed数字。你必须声明每个数字(例如:int a = 1; ...),这意味着我需要声明100个!!但那是不可能的,如果用户决定他将输入1000000个不同的3位数字怎么办?

帮帮我,请
Hi to all!

I have to write the following program.

1.User inputs a number (example: 5)
2.Then (because he entered 5) he enters 5 times, each time different,
3-placed number (example: 134, 256, 425, 253, 275)
3.then I have to find the lowest of those he entered and print it out

I have no idea how do I do that, because If the user enters a mubers
100 so he will input 100 different 3-placed numbers.you have to
declare each number (example: int a = 1;...)so that would mean that i
need to declare 100ints!! but thats impossible, what if the user
decides he is going to input 1000000 different 3-placed numbers?

help me out, please




不,你需要的只是两个变量。一个用户输入的最后一个号码是
,另一个用于最低号码。每次用户输入新的

数字时,检查它是否低于目前为止输入的最低数字,如果它是b / b,则更新到目前为止输入的最低数字。 />

当用户输入所有数字后,找到的最低数字为

远是所有输入数字的最低数字。


john



No, all you need is two variables. One for the last number the user entered
and one for the LOWEST NUMBER FOUND SO FAR. Each time the user enters a new
number check if it is lower than the lowest number entered so far and if it
is update the lowest number entered so far.

When the user has entered all the numbers then the lowest number found so
far will be the lowest number of all the numbers entered.

john




" vbmax" <峰; bs ***** @ yahoo.com> schrieb im Newsbeitrag

新闻:4d ************************** @ posting.google.c om ...

"vbmax" <bs*****@yahoo.com> schrieb im Newsbeitrag
news:4d**************************@posting.google.c om...
大家好!

我必须编写以下程序。

1.用户输入一个数字(例如:5)
2.然后(因为他进入5)他进入5次,每次不同,
3位数(例如:134,256,425,253,275)
3.然后我必须找到他输入的最低的并打印出来

我不知道我该怎么做,因为如果用户输入一个mubers
100所以他会输入100个不同的3-placed数字。你必须声明每个数字(例如:int a = 1; ...),这意味着我需要声明100个!!但那是不可能的,如果用户决定他将输入1000000个不同的3位数字怎么办?

帮帮我,请
Hi to all!

I have to write the following program.

1.User inputs a number (example: 5)
2.Then (because he entered 5) he enters 5 times, each time different,
3-placed number (example: 134, 256, 425, 253, 275)
3.then I have to find the lowest of those he entered and print it out

I have no idea how do I do that, because If the user enters a mubers
100 so he will input 100 different 3-placed numbers.you have to
declare each number (example: int a = 1;...)so that would mean that i
need to declare 100ints!! but thats impossible, what if the user
decides he is going to input 1000000 different 3-placed numbers?

help me out, please




开始并将问题归结为基本问题。你有一个输入

(1变量),你应该找到用户输入的最低数字(另一个变量)

。一种方法是存储所有变量并在之后执行最低数字的

测试。这当然可以使用

动态数组或标准容器来完成,但这是否真的有必要?


不,你可以通过测试来解决这个问题每个用户输入另一个值的最低数字

,因此你只需要两个

变量。但是,你应该记住一个陷阱 - 想想

你将在用户启动之前用来初始化变量的值

输入值和比较是第一次进行。


BTW - 用户将很难找到1000000个不同的三位数

数字;-)


HTH

克里斯



Start out and nail the problem down to the basic question. You have an input
(1 variable) and you should find the lowest number (another variable) that
the user entered. One way would be to store all variables and perform the
test for the lowest number afterwards. This can certainly be done with a
dynamic array or a standard container but is it really necessary?

No, you can simply solve this problem by testing for the lowest number each
time the user inputs another value and consequently you''ll only need two
variables. However, there is a pitfall you should keep in mind - think about
the value you''ll use to initialize your variables before the user starts
entering values and the comparison is performed for the first time.

BTW - the user will have a hard time finding 1000000 different three digit
numbers ;-)

HTH
Chris




" vbmax" <峰; bs ***** @ yahoo.com>在留言中写道

新闻:4d ************************** @ posting.google.c om ...

"vbmax" <bs*****@yahoo.com> wrote in message
news:4d**************************@posting.google.c om...
大家好!

我必须编写以下程序。

1.用户输入一个数字(例如:5)
2.然后(因为他进入5)他进入5次,每次不同,
3位数(例如:134,256,425,253,275)
3.然后我必须找到他输入的最低的并打印出来

我不知道我该怎么做,因为如果用户输入一个mubers
100所以他会输入100个不同的3-placed数字。你必须声明每个数字(例如:int a = 1; ...),这意味着我需要声明100个!!


提示:


int i;

i = 134;

i = 256 ;

i = 425;

但这是不可能的,如果用户决定他将输入1000000个不同的3位数字怎么办?
Hi to all!

I have to write the following program.

1.User inputs a number (example: 5)
2.Then (because he entered 5) he enters 5 times, each time different,
3-placed number (example: 134, 256, 425, 253, 275)
3.then I have to find the lowest of those he entered and print it out

I have no idea how do I do that, because If the user enters a mubers
100 so he will input 100 different 3-placed numbers.you have to
declare each number (example: int a = 1;...)so that would mean that i
need to declare 100ints!!
Hint:

int i;
i = 134;
i = 256;
i = 425;
but thats impossible, what if the user
decides he is going to input 1000000 different 3-placed numbers?




上次检查时,只有900个。但是你不需要
需要900件物品。


-Mike



Last time I checked, there were only 900 of them. But you don''t
need 900 objects.

-Mike


这篇关于帮助我的c ++示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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