计算范围内的对 [英] Counting Pairs in Range

查看:89
本文介绍了计算范围内的对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//给定输入:

1.整数列表

2.最小值

3.最大值



我们的目标是计算可以从列表构造的不同整数对的数量,而不重复使用,这样每对中的数字之和介于两者之间最小值和最大值(包含)。这些数字将以逗号分隔的字符串传递。



示例1:

数字:4,8,4,2,1 ,3

最低价:5

最高价:6



对数:2



例2:



数字:4,4,4

最低价: 8

最大值:8



对数:1

//Given inputs:
1. a list of integer numbers
2. a minimum value
3. a maximum value

Our goal is to compute the number of distinct pairs of integers that can be constructed from the list, without reuse, such that the sum of the numbers in each pair falls between the minimum and maximum values(inclusively). The numbers will be passes as comma-delimited string.

Example 1:
Numbers: "4,8,4,2,1,3"
Minimum: 5
Maximum: 6

Number of Pairs: 2

Example 2:

Numbers: "4,4,4"
Minimum: 8
Maximum: 8

Number of Pairs: 1

推荐答案

首先,家庭作业。

其次,你到目前为止尝试了什么?

第三,根本不是问题。

四,究竟是什么问题?



你不要指望我们做你的功课。

一开始看起来很难但如果你一个接一个地尝试,你就可以轻松完成。

如果您发现任何问题,请务必在此处发布您的问题。



不要直接询问对于源代码。如果你希望别人为你做功课,那还不是很完美。你必须自己这样做,这就是你学习的方法。



-KR
First, Homework.
Second, what have you tried so far ?
Third, not a question at all.
Fourth, what's the issue anyway ?

You don't expect us to do your homework.
It may seem difficult at first but if you try thing one after another you'll get it done easily.
And while trying if you find any issues, you can certainly post your question here.

But don't directly ask for the source code. If you expect others to do your homework for you, that's not quite done. You have to do it yourself and this way you'd learn.

-KR


这篇关于计算范围内的对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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