Forgot password?
 Register account
View 457|Reply 0

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

[Copy link]

3157

Threads

7925

Posts

610K

Credits

Credits
64218
QQ

Show all posts

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

Mobile version|Discuz Math Forum

2025-6-6 14:46 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit