marcioe Posted July 1, 2021 Report Share Posted July 1, 2021 Olá amigos, tudo bem Preciso ler uma (string/Texto) que na verdade está armazenando dezenas, e que está separada por PIPE Preciso saber quantas vezes e quais números repetem nela, separados por PIPE | Exemplo veja a String/texto 04|09|16|23|39|43|80|85|94|99 nenhuma dezena se repete 30|30|30|30|30|01|01|01|01|01 Já nessa o 30 e 01 Repete várias vezes 04|04|16|23|39|43|80|85|94|99 04 - 2 Vezes etc.. Preciso ter um retorno de qual(ais)dezena se Repetem Exemplo a primeira seria assim Não tem Repetidos Espero que tenham entendido Essa informação está dentro de uma tabela campo Char, cada um em uma linha da tabela Assim que fica no banco de dados 17|20|22|27|30|35|41|42|75|95 71|16|25|34|70|27|80|43|61|06 04|12|17|29|39|43|48|67|69|81 95|94|98|97|08|77|83|84|85|20 01|01|01|01|01|01|01|01|01|01 04|06|08|12|17|28|29|39|79|86 11|18|23|27|39|43|49|74|77|84 27|95|06|35|61|56|98|49|17|01 43|16|74|56|84|08|34|55|69|06 01|06|09|16|35|49|62|70|89|99 18|17|38|98|06|02|43|22|49|27 27|06|32|35|75|81|08|29|52|56 06|18|23|35|38|60|71|89|95|98 09|27|23|02|95|12|78|41|60|77 04|17|20|38|42|56|61|79|83|95 67|42|02|56|77|98|24|52|86|61 11|01|18|22|34|42|56|66|75|92 69|69|69|69|69|69|69|69|69|69 82|52|08|18|11|67|84|66|70|80 11|69|38|23|28|62|66|08|77|21 01|01|01|01|01|01|01|01|01|01 08|11|12|20|21|55|69|70|80|96 16|16|16|16|16|16|16|16|16|16 16|16|16|16|16|16|16|16|16|16 17|21|32|39|48|63|70|79|55|84 32|21|48|15|99|22|83|35|97|25 11|16|18|30|34|93|94|71|70|69 01|04|09|17|27|36|43|81|83|97 49|56|20|52|62|63|74|70|40|66 11|96|32|22|21|84|35|06|62|18 09|98|11|35|85|29|75|52|32|30 25|28|35|60|61|11|11|12|16|78 02|08|15|22|29|42|55|69|82|89 Quote Link to comment Share on other sites More sharing options...
Jmsilva Posted July 1, 2021 Report Share Posted July 1, 2021 #include "fivewin.ch" function Main() Local n,nPos,cData,aTokens,hModa:=Hash(),aKeys //cData := "04|09|16|23|39|43|80|85|94|99" //cData := "30|30|30|30|30|01|01|01|01|01" cData := "25|28|35|60|61|11|11|12|16|78" aTokens = hb_ATokens( cData, "|" ) For n:=1 to Len(aTokens) nPos := HGetPos( hModa, aTokens[n] ) IF nPos > 0 hModa[aTokens[n]] ++ ELSE hModa[aTokens[n]] := 1 ENDIF Next //Exibe assim aKeys := HGetKeys( hModa ) For n:=1 to Len(aKeys) ? aKeys[n], HGetValueAt( hModa,n ) Next //ou assim MsgStop(ValToPrg(hModa)) Return nil Quote Link to comment Share on other sites More sharing options...
edmandc Posted July 1, 2021 Report Share Posted July 1, 2021 #include "fivewin.ch" func main() Aarray := {} string1 = '30|30|30|30|30|01|01|01|01|01' * SEPARA TODOS OS ELEMENTOS SEM REPETIÇÃO y =1 for i=1 to 10 z=alltrim(str(i)) a&z = substr(string1,y,2) if ascan(aarray,a&z) = 0 aadd(aarray,a&z) endif y:= y+3 next *CONTA QUANTAS VEZES CADA ELEMENTO APARECE NA STRIG y=1 for i=1 to len(aarray) z=alltrim(str(i)) // ? 'elemento ' + padr(alltrim(aarray),2) elemento&z := numat( padr(alltrim(aarray),2), string1 ) ? 'elemento: ' + padr( alltrim( aarray),2 ) +' '+ alltrim(str(elemento&z)) + ' vez(es)' next retu Quote Link to comment Share on other sites More sharing options...
marcioe Posted July 1, 2021 Author Report Share Posted July 1, 2021 Obrigado pela resposta, vou testar mais tarde e retorno Quote Link to comment Share on other sites More sharing options...
edmandc Posted July 1, 2021 Report Share Posted July 1, 2021 tambem pode colocar no lugar de " for i=1 to 10" ponha: for i to numat( '"|", string1 ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.