voila lors d'un autre sujet ,j'ai pu avancer ,maintenant j'ai un autre problème
sur le resultat ..j'aimerai savoir combien il y a de numéro identique

cette routine que j'ai trouver ici ne semble pas fonctionner
elle recherche les nombre identique est devrais les additionner ,mais il me semble quel ne le fais pas
j'ai mis dans le fichier text des chiffre pour voir si cela fonctionner...
plus bas le programme entier pour ceux qui s interesse
donc ce qui me intéresse c'est les chiffre qui sont dans position, combien il se repete ..
merci de votre aide





Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
for(int ii=0; ii<tableauIndiceTrouve.length; ii++){
 
	        System.out.println("The number " + tableauIndiceTrouve[ii]/5 + " is repeted " + times[ii] + " times");
	    }
 
	}
 
	public static int recherche(int maValeur, int[] tab, int depart) {
		int monIndice = -1;
		for (int i = depart; monIndice == -1 && i < tab.length; i++) {
 
			if (maValeur == tab[i]) {
				// System.out.println(i);
				monIndice = i;
 
			}
		}
		return monIndice;
	}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package file;
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashMap;
import java.util.Map;
public class files {
 
	/**
         * Constructeur
         */
	public files() {
		int[] tableau = null; 
		//int[] tableau2=null; 
		int tableau3[]=new int[1000];
		int tableau4[]=new int[1000];
		int j=0;
		int x=0;
 
		try (BufferedReader b = new BufferedReader(new FileReader(new File("d:/taxe.txt")))) {
			String line;
			// Lecture du fichier ligne par ligne. Cette boucle se termine
			// quand la méthode retourne la valeur null.
			while ((line = b.readLine()) != null) {
 
				String[] args = line.split("\\s+");
 
				int[] lecture = new int[args.length - 1]; // on crée un tableau
															// temporaire pour
															// la lecture
 
				for (int i = 1; i < args.length; i++) {
 
					lecture[i - 1] = Integer.parseInt(args[i]);
 
				}
 
				if (tableau == null) {
					tableau = lecture;
				} else { // on va créer un tableau temporaire pour copier les 2
							// autres dedans
					int[] temp = new int[tableau.length + lecture.length];
					System.arraycopy(tableau, 0, temp, 0, tableau.length); // copie tableau dans temp 
					System.arraycopy(lecture, 0, temp, tableau.length, lecture.length); // copie lecture dans temp (même remarque que ligne précédente)
					tableau = temp;
				}
 
			}
 
 
		} catch (IOException e) {
			e.printStackTrace();
		}
 
		// affichage
 
		System.out.println("Valeurs dans tableau : ");
		for (int i = 0; i < tableau.length; i++) {
			System.out.print(tableau[i]);
			if (((i + 1) % 5) == 0) {
				System.out.println();
			} else {
				System.out.print(" ");
			}
		}
 
		int indiceTableau = 0;
		int[] tableauIndiceCherche = new int[tableau.length];
		int[] tableauIndiceTrouve = new int[tableau.length];
		for (int i = 0; i < tableau.length - 1; i++) {
 
			int indiceTrouve = recherche(tableau[i], tableau, i + 1);
			if (indiceTrouve >= 0) {
				// par exemple
				tableauIndiceCherche[indiceTableau] = i;
				tableauIndiceTrouve[indiceTableau] = indiceTrouve;
 
				indiceTableau++; // on passe à la case suivante
 
			}
 
		}
 
		// afichage des résultats
		for(int i=0; i<indiceTableau; i++) {
			System.out.println("La valeur tableau[" + tableauIndiceCherche[i]+"]="+tableau[tableauIndiceCherche[i]]+" a été trouvée en double en position " + (tableauIndiceTrouve[i]/5) + ": tableau["+tableauIndiceTrouve[i]+"]="+tableau[tableauIndiceTrouve[i]]);
			//System.out.println(tableau[tableauIndiceTrouve[i]]);
 
			//tableau2[i]=tableau[tableauIndiceTrouve[i]];
		}
		Arrays.sort(tableauIndiceTrouve);
 
		int times[] = new int[tableauIndiceTrouve.length];
 
	    for(int i=0; i<tableauIndiceTrouve.length; i++){
	        int number = tableauIndiceTrouve[i];
	        for(int ii=0; ii<tableauIndiceTrouve.length; ii++){
	            if(number == tableauIndiceTrouve[ii]/2){
	                times[i]++;
 
	            }
	        }     
	    }
	    for(int ii=0; ii<tableauIndiceTrouve.length; ii++){
 
	        System.out.println("The number " + tableauIndiceTrouve[ii]/5 + " is repeted " + times[ii] + " times");
	    }
 
	}
 
	public static int recherche(int maValeur, int[] tab, int depart) {
		int monIndice = -1;
		for (int i = depart; monIndice == -1 && i < tab.length; i++) {
 
			if (maValeur == tab[i]) {
				// System.out.println(i);
				monIndice = i;
 
			}
		}
		return monIndice;
	}
 
	/**
         * MAIN
         */
	public static void main(String[] args) {
		// On lance notre lire fichier
		new files();
	}
}