marcioe Posted May 18, 2021 Report Share Posted May 18, 2021 Olá amigos, boa tarde Preciso fazer um Mapa de troco, Exemplo R$ 45,30 4 Nota(s) de R$ 10,00 1 Nota(s) de R$ 5,00 3 Moedas de R$ 0,10 Algo assim Quote Link to comment Share on other sites More sharing options...
lucimauromelo Posted May 20, 2021 Report Share Posted May 20, 2021 O acbr tem o acbrtroco para essa finalidade se não me engano. Quote Link to comment Share on other sites More sharing options...
emotta Posted May 20, 2021 Report Share Posted May 20, 2021 Rascunhei agora essa funcão, nos testes rápidos que fiz deu certo. Veja se ela te ajuda e se tiver algo errado corrija e poste aqui caso alguem precise no futuro Function u_Main() Local nValor := 287.77 aTroco := CalculaNotas(nValor) MsgStop(Sr_ShowVector(aTroco)) Return Static Function CalculaNotas(nValor) Local aNotas := {200, 100, 50, 20, 10, 5, 2, 1, .50, .25, .10, .05, .01} Local nDif := nValor * 100 Local nI Local aTroco := {} Local nCedulas For nI := 1 to Len(aNotas) aNotas[nI] := aNotas[nI] * 100 Next For nI := 1 to Len(aNotas) nCedulas := Int(nDif / aNotas[nI]) nDif := nDif - (nCedulas * aNotas[nI]) If nCedulas > 0 aadd(aTroco, {aNotas[nI]/100, nCedulas}) EndIf Next Return aTroco Quote Link to comment Share on other sites More sharing options...
kapiaba Posted May 20, 2021 Report Share Posted May 20, 2021 1 hora atrás, emotta disse: Eduardo: MsgStop( Sr_ShowVector( aTroco ) ) Who is this? Abs Quote Link to comment Share on other sites More sharing options...
marcioe Posted May 20, 2021 Author Report Share Posted May 20, 2021 top isso mesmo obrigado a todos Quote Link to comment Share on other sites More sharing options...
emotta Posted May 21, 2021 Report Share Posted May 21, 2021 16 horas atrás, kapiaba disse: MsgStop( Sr_ShowVector( aTroco ) ) Who is this? Abs é uma função do SQLRDD que exibe em texto um array, pode ignorar pois isso não tem referencia nenhuma a funcionalidade, é apenas uma maneira fácil de exibir um array na tela. Quote Link to comment Share on other sites More sharing options...
marcioe Posted May 21, 2021 Author Report Share Posted May 21, 2021 Basta Rodar assim que já tem o resultado Xbrowse(aTroco) Top o resto é fazer os ajustes conforme for preciso 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.