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
| package superse;
import java.io.*;
import java.io.File;
import java.io.FileReader;
import java.util.Arrays;
public class superses
{
int [] tableau;
int [] tableau2=new int[91];
int [] tableau3=new int [91];
int n=1;
int n2=1;
/**
* Constructeur
*/
public superses()
{
try(BufferedReader b = new BufferedReader( new FileReader( new File("D:/Fichierse.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) {
// STOCK LA LIGNE DANS UN BUFFER
// String tmp = b.readLine();
// COUPE LA LIGNE SUIVANT LES ESPACES
String [] args = line.split("\\s+");
// ALLOUE NOTRE TABLEAU DE N ELEMENTS
tableau = new int[args.length];
// COPIE CHAMP A CHAMP + AFFICHAGE
for( int i=0;i<tableau.length;i++)
{
tableau[i] = Integer.parseInt( args[i] );
if (tableau2[tableau[i]]!=tableau[i])
{
if(n2>70)
{
tableau3[n2]=tableau[i];
}
tableau2[tableau[i]]=tableau[i];
n2++;
//System.out.println("reste "+(90-n2));
}
// System.out.println( tableau[i]+" "+n );
}
}
Arrays.sort(tableau3);
for( int i=1;i<91;i++)
{
if ( tableau3[i]!=0)
{
System.out.print(tableau3[i]+" ");
}
}
}
catch( IOException e )
{
// System.out.println("Erreur, le fichier n'existe pas ou est mal formaté");
e.printStackTrace();
}
}
/**
* MAIN
*/
public static void main( String [] args )
{
// On lance notre lire fichier
new superses();
}
} |
Partager