Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class testTabNonTriee {
- //private static int [] tabEntiers;
- private static final int TAILLE = 10;
- //private int nombreDEntiers;
- static int[] tabEntiers = {3,4,5};
- public static void main(String[] args) {
- // tabEntiers = new int[TAILLE];
- // nombreDEntiers = 0;
- //
- //
- // tabEntiers[0] = 1;
- // tabEntiers[1] = 3;
- // tabEntiers[2] = 3;
- // tabEntiers[3] = 4;
- // tabEntiers[4] = 3;
- //nombreDEntiers = 3;
- supprimerOccurences(5);
- for (int i=0 ; i<tabEntiers.length ; i++) {
- System.out.println(tabEntiers[i]);
- }
- }
- private static void supprimerOccurences(int unEntier) {
- int suppression = 0;
- int nombreDEntiers = 3;
- int i=0;
- while(i<nombreDEntiers) {
- if(tabEntiers[i]==unEntier) {
- nombreDEntiers--;
- tabEntiers[i] = tabEntiers[nombreDEntiers];
- for (int j=i ; j<nombreDEntiers ; j++)
- if(tabEntiers[nombreDEntiers] == tabEntiers[j]) {
- tabEntiers[nombreDEntiers] = 0;
- }
- }
- else {
- i++;
- }
- }
- // while(i<nombreDEntiers){
- // if(tabEntiers[i]==unEntier){ //i = [0] (2)
- //
- // for (int j = i ; j<nombreDEntiers-1 ; j++) { // T1 :j=0, donc i=0 au 1er tour ; j=0 < 4 ; j+1 , T2 : j=1, i=1 & <2
- // tabEntiers[j] = tabEntiers[j+1]; // tabEntiers index 0 = tabEntiers index 1
- // // tabEntiers[nombreDEntiers-1] = 0; //tabEntiers[3] aura la valeur 0
- // //tabEntier2
- // nombreDEntiers--;
- //
- //
- // }
- //
- // }
- // else{
- // i++; //T1 : i=1
- // for(int j=i ; j<nombreDEntiers ;j++) {
- // if(tabEntiers[j-1] == tabEntiers[j]) {
- // tabEntiers[j+1] = 0;
- // }
- // }
- // if(tabEntiers[i-1] == tabEntiers[i] ) {
- // tabEntiers[i] = tabEntiers[i+1];
- // tabEntiers[i+1] = 0;
- // }
- //
- // suppression++;
- //
- // }
- //
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement