Bonjour à tous,
J'ai besoin de trouver un algorithme mieux optimisé pour pouvoir diviser un nombre par un autre. Les nombres sont contenu dans des tableaux où chaque cellule contient un chiffre (ex.: 123 =
{1,2,3}). Voici le mien, qui est vraiment très lent... :
public static int[] hugeDiv(int []n1 , int[] n2 ){
int[]zero = new int[1];
zero[0]=0;
int[] un = new int[1];
un[0]=1;
if(isEqual(n1,n2) == true) return un;
if(isSmaller(n1,n2) == true) return zero;
int[] resultat = new int[n1.length];
int[] tmp;
int[] n2foisj;
for(int i=0;i<resultat.length;i++){
n2foisj = hugeCopy(zero);
tmp = hugeGetPart(n1,i+1);
for(int j=0;isSmaller(n2foisj,tmp)==true;j++){
resultat[i] = j;
n2foisj = hugeMultDigit(n2,j+1);
if(n2foisj==null) n2foisj = hugeCopy(zero);
}
resultat[i] = resultat[i]%10;
tmp = hugeSub(tmp,n2foisj);
}
return resultat;
}
toutes les autres fonctions marchent impécablement(hugeMult=*,hugeSub=-,hugeGetPart([],i)=retourne les i premiers digits du tableau []).
Merci d'Avance =D