在数组中重复 [英] duplicates in array

查看:68
本文介绍了在数组中重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在

单循环中找到数组中的重复(重复)元素?


AK

Is it possible to find repeated(duplicate) element in an array in
single loop ?

AK

推荐答案

在文章< 11 ******************** @ u36g2000prd.googlegroups.c om>中,

ak< aj ********** @ gmail.comwrote:
In article <11********************@u36g2000prd.googlegroups.c om>,
ak <aj**********@gmail.comwrote:

>是否有可能找到
单循环中的重复(重复)元素?
>Is it possible to find repeated(duplicate) element in an array in
single loop ?



数组是按排序顺序排列的吗?重复是否相邻?请问

只是一个重复的元素,或者可能有几个?b $ b几个?,所有必须找到的重复项?

数组元素是整数还是浮点数?是否有已知的最低值?b $ b和最大限制?是否有必须输出

重复项的特定订单?是否足以输出元素

和重复数量,或者必须输出每个元素的位置?


如果足以输出重复的元素和

副本的数量,答案是肯定的,只要有足够的内存可用。


-

我是那些日子很年轻,但我也很朦胧。

- 克里斯托弗牧师

Is the array in sorted order? Are the duplicates adjacent? Will there
be exactly one element which is duplicated, or might there be
several?, the duplicates of all of which must be found? Are the
array elements integral or floating point? Is there a known minimum
and maximum bound on them? Is there a particular order that the
duplicates must be output in? Is it sufficient to output the element
and the number of duplicates, or must the locations of each be output?

If it is sufficient to output the duplicated elements and number of
duplicates, the answer is Yes, provided that enough memory is available.

--
I was very young in those days, but I was also rather dim.
-- Christopher Priest


5月21日下午6:47,ak < ajinkya.c ... @ gmail.comwrote:
On May 21, 6:47 pm, ak <ajinkya.c...@gmail.comwrote:

是否可以在
$ b $中找到数组中的重复(重复)元素b单循环?
Is it possible to find repeated(duplicate) element in an array in
single loop ?



当然。只要你不介意循环有很多

迭代。


for(k = 0; k< n * n; ++ k){

i = k / n; j = k%n;

...

}

Of course. As long as you don''t mind if the loop has quite a lot of
iterations.

for (k = 0; k < n*n; ++k) {
i = k / n; j = k % n;
...
}


文章< 11 *********************@y2g2000prf.googlegroups.c om>,

christian.bau< ch ****** *****@cbau.wanadoo.co.ukwrote:
In article <11*********************@y2g2000prf.googlegroups.c om>,
christian.bau <ch***********@cbau.wanadoo.co.ukwrote:

> 5月21日下午6:47,ak< ajinkya.c ... @ gmail.comwrote:
>On May 21, 6:47 pm, ak <ajinkya.c...@gmail.comwrote:

>是否可以在
单循环中找到数组中的重复(重复)元素?
>Is it possible to find repeated(duplicate) element in an array in
single loop ?


>当然。只要你不介意循环有很多的迭代。
>Of course. As long as you don''t mind if the loop has quite a lot of
iterations.



哦,非常聪明!


- Richard

-

考虑在一些字母表中需要多达32个字符

- 1963年的X3.4。

Ooh, very clever!

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


这篇关于在数组中重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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