Sign in to follow this  
Followers 0
Ashalshaikh

Get the repeated words !!

3 posts in this topic

Hi !!

First :: My English Is Bad , So I'm Sorry >_<

-----

I Want TO Get the repeated words !! In Array !!

Like !!

$Array[5] = [1, 2, 1, 2, 1]

I Want To Get

0+2+4

1+3

I tried this...

But It Need Some Thing :(

Local $Array[5] = [1, 2, 1, 2, 1]
;===============
Local $x = 0, $y = 0, $RES
Do
    Do
        If $Array[$x] = $Array[$y] Then
            $RES &= $x & "+" & $y & "+"
        EndIf
        $y += 1
    Until $y = UBound($Array)
    $RES = StringTrimRight($RES, 1) & "#"
    $x += 1
    $y = 0
Until $x = UBound($Array)
$RES = StringTrimRight($RES, 1)
;===============
MsgBox(0, "", $RES)

Thank you !!

Share this post


Link to post
Share on other sites



Hi !!

First :: My English Is Bad , So I'm Sorry :whistle:

-----

I Want TO Get the repeated words !! In Array !!

Like !!

$Array[5] = [1, 2, 1, 2, 1]

I Want To Get

0+2+4

1+3

I tried this...

But It Need Some Thing :idiot:

Local $Array[5] = [1, 2, 1, 2, 1]
;===============
Local $x = 0, $y = 0, $RES
Do
    Do
        If $Array[$x] = $Array[$y] Then
            $RES &= $x & "+" & $y & "+"
        EndIf
        $y += 1
    Until $y = UBound($Array)
    $RES = StringTrimRight($RES, 1) & "#"
    $x += 1
    $y = 0
Until $x = UBound($Array)
$RES = StringTrimRight($RES, 1)
;===============
MsgBox(0, "", $RES)

Thank you !!

This example may help you.

You should be able to change the output format of the $ResDisp variable to whatever you want to display.

;
Local $Array[12] = [6, "the", 1, 2, 1, 2, 6, 1, "the", 1, 6, 2]

Local $ResDisp = "", $ResTest = ""

For $index = 0 To UBound($Array) - 2
    If StringInStr($ResTest, $Array[$index]) = 0 Then
        $ResTest &= $Array[$index] & " "
        $ResDisp &= $Array[$index] & @TAB & " (" & $index & "+"
        $y = $index + 1
        Do
            If $Array[$index] = $Array[$y] Then
                $ResDisp &= $y & "+"
            EndIf
            $y += 1
        Until $y = UBound($Array)
        $ResDisp = StringTrimRight($ResDisp, 1) & ")" & @CRLF
    EndIf
Next
$ResDisp = StringTrimRight($ResDisp, 1)

MsgBox(0, "Results", $ResDisp)
;

Share this post


Link to post
Share on other sites

This example may help you.

You should be able to change the output format of the $ResDisp variable to whatever you want to display.

;
Local $Array[12] = [6, "the", 1, 2, 1, 2, 6, 1, "the", 1, 6, 2]

Local $ResDisp = "", $ResTest = ""

For $index = 0 To UBound($Array) - 2
    If StringInStr($ResTest, $Array[$index]) = 0 Then
        $ResTest &= $Array[$index] & " "
        $ResDisp &= $Array[$index] & @TAB & " (" & $index & "+"
        $y = $index + 1
        Do
            If $Array[$index] = $Array[$y] Then
                $ResDisp &= $y & "+"
            EndIf
            $y += 1
        Until $y = UBound($Array)
        $ResDisp = StringTrimRight($ResDisp, 1) & ")" & @CRLF
    EndIf
Next
$ResDisp = StringTrimRight($ResDisp, 1)

MsgBox(0, "Results", $ResDisp)
;

WOW

Very Smart

Thank You !!

I am grateful to you ..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0