ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le
message
E:\divers\ets\LOG\log320\aut03\lab1>java Sort
Exception in thread "main" java.lang.ClassCastException
at Sort.radixSort(Sort.java:30)
at Sort.statistique(Sort.java:101)
at Sort.main(Sort.java:139)
Long[]a;
long baro=0;
long[][] tabStat= new long[50][6];
int maxTest=50;
//algo du tri radixSort
public void radixSort( Long a[], int k, int log) {
LinkedList[] list = new LinkedList[ log ];
for( int i = 0; i < log; i++ ){
list[ i ] = new LinkedList( );
baro++;
}
LinkedList tmpList = new LinkedList( );
for( int i = 0; i < a.length; i++ ){
tmpList.addLast( a[ i ] );
baro++;
}
for( int i = 0, mult = 1; i < k; i++ ) {
while( !tmpList.isEmpty( ) ) { //ligne 30
Long p = (Long)tmpList.removeFirst( );
list[ ( p.intValue( ) / mult ) % log ].addLast( p );
baro++;
}
for( int j = 0; j < log; j++ ) {
tmpList.addAll( list[ j ] );
list[ j ].clear( );
baro++;
}
mult *= log;
}
tmpList.toArray( a );
}
//ecrire les valeurs du tableau dans le tableau
public void ecrireFichier(Long a[], String NomFichier){
try{
PrintWriter out = new PrintWriter(new FileWriter(NomFichier));
for (int i = 0; i < a.length; i++)
out.println(a[i]);
out.close();
}
catch(Exception e){
e.printStackTrace();
}
}
//ecrire les valeurs des barometre
public void ecrireBaro(long[][] tabStat, String NomFichier){
try{
PrintWriter out = new PrintWriter(new FileWriter(NomFichier));
for(int i=0;i<maxTest;i++){
out.println(tabStat[i][0] );
out.println(tabStat[i][1] );
out.println(tabStat[i][2] );
out.println(tabStat[i][3] );
out.println(tabStat[i][4] );
out.println(tabStat[i][5] );
out.println("=============" );
out.close();
}
}
catch(Exception e){
e.printStackTrace();
}
}
//genenerer les valeurs pour le tableau
public void genererTableau(Long a[]){
long rang=4294967296l; //rang
Random r1 = new Random();
for (int i=0;i<a.length;i++){
a[i] = new Long ( (long) (r1.nextDouble()*rang));
}
}
public void statistique(){
int n=100; //nombre d'élément du tableau
a = new Long[n];
Long []original;
original = new Long[n];
for(int i=0;i<maxTest;i++){
genererTableau(original);
a=(Long[])original.clone();
//base 2 - passe k
radixSort( a, 32,2 ); //ligne 101
tabStat[i][0]=baro;
//base 8 - passe k/3
a=(Long[])original.clone( );
baro=0;
radixSort( a, 32/3,8 );
tabStat[i][1]=baro;
//base 16 - passe k/4
a=(Long[])original.clone( );
baro=0;
radixSort( a, 32/4,16 );
tabStat[i][2]=baro;
//base 64 - passe k/6
a=(Long[])original.clone( );
baro=0;
radixSort( a, 32/6,64 );
tabStat[i][3]=baro;
//base racine(n) - passe k/log2(racine(n))
a=(Long[])original.clone( );
baro=0;
radixSort( a, (int)(Math.sqrt(n)),
(int)(32/(Math.log(Math.sqrt(n))/Math.log(2.0))) );
tabStat[i][5]=baro;
//base racine 3ieme(n) - passe k/log2(racine 3ieme(n))
a=(Long[])original.clone( );
baro=0;
radixSort( a, (int)(Math.pow(3,1/n)),
(int)(32/(Math.log(Math.pow(3,1/n))/Math.log(2.0))) );
tabStat[i][6]=baro;
}
ecrireBaro(tabStat,"stat.txt");
}
public static void main( String[] args ) {
Sort tmp = new Sort();
tmp.statistique(); //ligne 139
}
}
une idée?
--
Borland rulez http://pages.infinit.net/borland
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Olivier Thomann
On Fri, 31 Oct 2003 15:14:47 -0500, os2 wrote:
salut salut
ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le message
E:diversetsLOGlog320aut03lab1>java Sort Exception in thread "main" java.lang.ClassCastException at Sort.radixSort(Sort.java:30) at Sort.statistique(Sort.java:101) at Sort.main(Sort.java:139) J'obtiens plutôt:
java.lang.ArrayIndexOutOfBoundsException: -1 at Sort.radixSort(Sort.java:25) at Sort.statistique(Sort.java:83) at Sort.main(Sort.java:115) Exception in thread "main"
Et je pense que tu ne passes pas assez longtemps à débugger ton programme avant de poster sur les news. Le premier problème était identifiable en trois secondes. -- Olivier
On Fri, 31 Oct 2003 15:14:47 -0500, os2 <os2l@nospamvideotron.ca>
wrote:
salut
salut
ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le
message
E:diversetsLOGlog320aut03lab1>java Sort
Exception in thread "main" java.lang.ClassCastException
at Sort.radixSort(Sort.java:30)
at Sort.statistique(Sort.java:101)
at Sort.main(Sort.java:139)
J'obtiens plutôt:
java.lang.ArrayIndexOutOfBoundsException: -1
at Sort.radixSort(Sort.java:25)
at Sort.statistique(Sort.java:83)
at Sort.main(Sort.java:115)
Exception in thread "main"
Et je pense que tu ne passes pas assez longtemps à débugger ton
programme avant de poster sur les news.
Le premier problème était identifiable en trois secondes.
--
Olivier
ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le message
E:diversetsLOGlog320aut03lab1>java Sort Exception in thread "main" java.lang.ClassCastException at Sort.radixSort(Sort.java:30) at Sort.statistique(Sort.java:101) at Sort.main(Sort.java:139) J'obtiens plutôt:
java.lang.ArrayIndexOutOfBoundsException: -1 at Sort.radixSort(Sort.java:25) at Sort.statistique(Sort.java:83) at Sort.main(Sort.java:115) Exception in thread "main"
Et je pense que tu ne passes pas assez longtemps à débugger ton programme avant de poster sur les news. Le premier problème était identifiable en trois secondes. -- Olivier
os2
Olivier Thomann wrote:
On Fri, 31 Oct 2003 15:14:47 -0500, os2 wrote:
salut
salut
ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le message
E:diversetsLOGlog320aut03lab1>java Sort Exception in thread "main" java.lang.ClassCastException at Sort.radixSort(Sort.java:30) at Sort.statistique(Sort.java:101) at Sort.main(Sort.java:139)
J'obtiens plutôt: java.lang.ArrayIndexOutOfBoundsException: -1 at Sort.radixSort(Sort.java:25) at Sort.statistique(Sort.java:83) at Sort.main(Sort.java:115) Exception in thread "main"
j'obtient pas ça
Et je pense que tu ne passes pas assez longtemps à débugger ton programme avant de poster sur les news.
quelques heure je trouve ça assez
Le premier problème était identifiable en trois secondes. -- Olivier
-- Borland rulez http://pages.infinit.net/borland
Olivier Thomann wrote:
On Fri, 31 Oct 2003 15:14:47 -0500, os2 <os2l@nospamvideotron.ca>
wrote:
salut
salut
ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le
message
E:diversetsLOGlog320aut03lab1>java Sort
Exception in thread "main" java.lang.ClassCastException
at Sort.radixSort(Sort.java:30)
at Sort.statistique(Sort.java:101)
at Sort.main(Sort.java:139)
J'obtiens plutôt:
java.lang.ArrayIndexOutOfBoundsException: -1
at Sort.radixSort(Sort.java:25)
at Sort.statistique(Sort.java:83)
at Sort.main(Sort.java:115)
Exception in thread "main"
j'obtient pas ça
Et je pense que tu ne passes pas assez longtemps à débugger ton
programme avant de poster sur les news.
quelques heure je trouve ça assez
Le premier problème était identifiable en trois secondes.
--
Olivier
ce compile le code ci-dessous aucune erreur mais à l'exécution j'ai le message
E:diversetsLOGlog320aut03lab1>java Sort Exception in thread "main" java.lang.ClassCastException at Sort.radixSort(Sort.java:30) at Sort.statistique(Sort.java:101) at Sort.main(Sort.java:139)
J'obtiens plutôt: java.lang.ArrayIndexOutOfBoundsException: -1 at Sort.radixSort(Sort.java:25) at Sort.statistique(Sort.java:83) at Sort.main(Sort.java:115) Exception in thread "main"
j'obtient pas ça
Et je pense que tu ne passes pas assez longtemps à débugger ton programme avant de poster sur les news.
quelques heure je trouve ça assez
Le premier problème était identifiable en trois secondes. -- Olivier