Forgot password?
 Create new account
View 353|Reply 0

找出列表中重复的元素的位置

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-6-30 17:04:39 |Read mode
Last edited by hbghlyj at 2021-6-30 17:53:00FindDuplicates =
Function[x, Module[{counts}, counts = Select[Counts[x], # > 1 &];
   Flatten[Position[x, #]] & /@ Keys[counts]]]
示例
S = RandomInteger[{1, 1000}, 2000];
FindDuplicates[S]

手机版Mobile version|Leisure Math Forum

2025-4-20 22:14 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list