Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need Math Whiz - Frankenbach ?
Message
De
16/02/2005 11:16:12
 
 
À
16/02/2005 09:29:54
Chris Bohling
Myers and Stauffer LC
Shawnee, Kansas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00987308
Message ID:
00987474
Vues:
34
I'm not sure I understand. Using v=10 and n=3 I should get 4,4,2

This is a client requirement. A value is going to be entered into N rows in a grid. The n is a number determined by the operator. The value v is to be equally distributed among the rows, maintaining integer values. If necessary, the number will be equally distributed in n-1 rows and then the modulus in the nth row so that the total of the rows = the original V

In your example if I substitute v=10, n=3 I get 5 and 0 - only two rows.

>
>CLEAR
>
>v = 10^10 + 459  &&14912   &&243   &&15  &&10  &&1787  &&27
>n = 10           &&7       &&5     &&4   &&3   &&14    &&5
>
>nRemainder = INT(v%n)
>nIntCount = n
>
>IF nRemainder > 0
>	nIntCount = nIntCount - 1
>	nInteger = INT( v / (n-1) )
>	nRemainder = v%nInteger
>ELSE
>	nInteger = v/n
>ENDIF
>
>? nInteger
>? nRemainder
>? (nInteger * nIntCount) + nRemainder
>
>RETURN
>


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform