Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

/* Mohamed Anis MEKKI - 2003 (c) */ public class source { symbol symbols[]; int length; public source() { this.length = 0; this.symbols = new symbol[10000]; } public void add_symbol(symbol s) { (this.symbols)[this.length] = s; (this.length)++; } public void show() { int i=0; while (i < this.length) { ((this.symbols)[i]).show(); i++; } } public source extend2() { int i=0; int j=0; int k=0; source source2 = new source(); source2.length = (this.length)*(this.length); while (i ((this.symbols)[i+1]).prob )// if 1 { permut = (this.symbols)[i]; (this.symbols)[i] = (this.symbols)[i+1]; (this.symbols)[i+1] = permut; notyet = true; }// end if 1 i++; }// end while 1 }// end while 2 }// end classify_down() public static void main(String args[]) { source M = new source(); source M2 = new source(); symbol a1 = new symbol("A1",0.8); symbol a2 = new symbol("A2",0.1); symbol a3 = new symbol("A3",0.1); M.add_symbol(a1); M.add_symbol(a2); M.add_symbol(a3); System.out.println("Taille de la source M : "+M.length); M.show(); System.out.println(); System.out.println("Taille de l'extension 2 de la source M: "+(M.extend2()).length); M2 = M.extend2(); M2.show(); System.out.println(); System.out.println("L'extension 2 de la source M Triée selon probabilités croissantes"); M2.classify_up(); M2.show(); System.out.println(); System.out.println("L'extension 2 de la source M Triée selon probabilités décroissantes"); M2.classify_down(); M2.show(); } }