Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need Math Whiz - Frankenbach ?
Message
 
 
À
16/02/2005 14:49:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00987308
Message ID:
00988805
Vues:
65
ok so I think he wants.

10 into 1 returns 10
10 into 2 returns 5,5
10 into 3 returns 4,4,2
10 into 4 returns 3,3,3,1
10 into 5 returns 2,2,2,2,2

past that gets tricky, 6 I guess would be 1,1,1,1,1,5 and 9 would be - 8 1's and a 2

so the routine needs to ceiling() up to 10/2 and int() past that. oh and anything that divides straight in we'll just return.

ok here's the routine for 3

inum = 3
out1 = 0
out2 = 0
if 10 % inum == 0 && just output if divides perfectly
out1 = 10/inum
out2 = 0
else
if inum < int(10/2) && int here because you'd want the int side of an 11/2
out1 = ceiling(10/inum)
else
out1 = int(10/inum)
endif
out2 = 10 - out1*(inum-1)
endif
? out1
? out2

&&you now know that if out2 is 0 then its out1 * inum
&&otherwise it's (inum - 1) * inum + out2

so replace those 10's with a variable and it should work I think, hope that's what you were going for.

Ken.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform