/* Tests d'affectation entre tableaux */ public class AffectationEntreTableaux { /* Action d'affichage d'un tableau d'entiers */ static void affichage(int [] t) { int i; for ( i = 0 ; i < t.length ; i = i+1 ) { Ecran.afficher(t[i]," "); } Ecran.sautDeLigne(); } /* Action d'affectation des composantes */ /* d'un tableau d'entiers cible */ /* avec les composantes */ /* d'un tableau d'entier source */ static void affectation(int [] source,int [] cible) { int i; for ( i = 0 ; i < source.length ; i = i+1 ) { cible[i] = source[i]; } } /* Programme principal */ public static void main(String [] args) { int [] t1 = { 0,1,2,3 }; int [] t2 = { 0,0,0,0 }; int [] t3 = { 3,2,1,0 }; affichage(t1); affichage(t2); affectation(t1,t2); affichage(t1); affichage(t2); t1[0] = 0; t1[1] = 0; t1[2] = 0; t1[3] = 0; affichage(t1); affichage(t2); Ecran.sautDeLigne(); affichage(t1); affichage(t3); t1 = t3; affichage(t1); affichage(t3); t1[0] = 0; t1[1] = 0; t1[2] = 0; t1[3] = 0; affichage(t1); affichage(t3); } }