Find a number repeated on a array

Find a number repeated on a array

Postby Silvio.Falconi » Wed Jun 01, 2022 8:08 am

i have to find in an array
the numbers repeated from column 2 to column 6
and numbers in the same positions from column 2 to column 6
obviously saving the x, y positions


the array


Code: Select all  Expand view
function aData1_array() //for demo
return ;
{  {"Bari",89,58,55,31,67,24,12,44,3,8,573,549,523,545,517} ;
,  {"Cagliari",1,88,79,80,59,47,4,10,0,27,392,392,368,404,362} ;
,  {"Firenze",47,4,41,62,65,12,8,5,30,6,580,520,553,584,559} ;
,  {"Genova",67,7,5,46,44,8,12,4,4,21,373,385,378,365,380} ;
,  {"Milano",57,43,64,58,17,7,55,12,15,52,547,537,529,572,562} ;
,  {"Napoli",56,79,14,37,90,52,57,16,11,5,542,541,566,560,564} ;
,  {"Palermo",53,37,39,24,86,4,6,3,13,8,538,538,582,564,559} ;
,  {"Roma",32,7,18,57,44,3,1,16,27,14,557,538,593,551,545} ;
,  {"Torino",64,44,31,70,20,17,14,7,27,25,565,528,606,571,592} ;
,  {"Venezia",86,67,64,58,22,8,38,10,0,8,640,551,595,565,596} ;
,  {"Nazionale",17,47,77,1,6,10,37,22,13,23,181,148,151,135,149} ;
}


my test


Code: Select all  Expand view
#include "Fivewin.ch"

Function test()
local aData:=aData1_array()
local nNumero:=0
local nSeek:=0
local aNumeri := {}
local nRow,ncol,nAt
local nOldRow:= 1,nOldCol:=1

  For nRow=1 to Len(aData)
     For nCol= 2 to 6
             nSeek:= Adata[nRow][nCol]

          if ( nAt := AScan( aData, { |a| a[ nCol ] == nNumero } ) ) > 0
               aadd(aNumeri, {nSeek,nRow,nCol})
               aadd(aNumeri,  {nNumero,nOldRow,nOldCol})
            endif

         nNumero:= nSeek
         nOldRow:=nRow
         nOldCol:=nCol


      Next
   Next

   xbrowser aNumeri



function aData1_array() //for demo
return ;
{  {"Bari",89,58,55,31,67,24,12,44,3,8,573,549,523,545,517} ;
,  {"Cagliari",1,88,79,80,59,47,4,10,0,27,392,392,368,404,362} ;
,  {"Firenze",47,4,41,62,65,12,8,5,30,6,580,520,553,584,559} ;
,  {"Genova",67,7,5,46,44,8,12,4,4,21,373,385,378,365,380} ;
,  {"Milano",57,43,64,58,17,7,55,12,15,52,547,537,529,572,562} ;
,  {"Napoli",56,79,14,37,90,52,57,16,11,5,542,541,566,560,564} ;
,  {"Palermo",53,37,39,24,86,4,6,3,13,8,538,538,582,564,559} ;
,  {"Roma",32,7,18,57,44,3,1,16,27,14,557,538,593,551,545} ;
,  {"Torino",64,44,31,70,20,17,14,7,27,25,565,528,606,571,592} ;
,  {"Venezia",86,67,64,58,22,8,38,10,0,8,640,551,595,565,596} ;
,  {"Nazionale",17,47,77,1,6,10,37,22,13,23,181,148,151,135,149} ;
}

 


Perhaps it found something but save only the number founded
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6890
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 16 guests