Advertisement
weeez

lotto

May 29th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. package lotto;
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5.  
  6. public class Lotto {
  7.  
  8.     public static void main(String[] args) throws IOException {
  9.        
  10.         String file = "lotto.txt";
  11.         String kiFile = "eredmeny.txt";
  12.  
  13.         Reader reader = new FileReader(file);  
  14.         Writer writer = new FileWriter(kiFile);
  15.         Scanner sc = new Scanner(reader);
  16.         List<String> sorok = new ArrayList<>();
  17.         String[] szamok;
  18.         int[] lottoSzamok = new int[5];
  19.         int[] nyeroSzamok = new int[90];
  20.    
  21.         while(sc.hasNext()){
  22.             sorok.add(sc.nextLine());
  23.         }
  24.        
  25.         try{
  26.             for(String a: sorok){
  27.                 szamok = a.split(" ");      
  28.                 lottoSzamok[0] = Integer.parseInt(szamok[15]);
  29.                 lottoSzamok[1] = Integer.parseInt(szamok[16]);
  30.                 lottoSzamok[2] = Integer.parseInt(szamok[17]);
  31.                 lottoSzamok[3] = Integer.parseInt(szamok[18]);
  32.                 lottoSzamok[4] = Integer.parseInt(szamok[19]);
  33.  
  34.                 for(int i: lottoSzamok){
  35.                     //System.out.print(i + " ");
  36.                     ++nyeroSzamok[i-1];
  37.                 }
  38.                 //System.out.println();
  39.             }
  40.         }
  41.         catch(NumberFormatException e){          
  42.         }
  43.        
  44.         int szamlalo = 1;
  45.         int counter = 1;
  46.        
  47.         String sor = "";
  48.         for(int i : nyeroSzamok){
  49.             if(counter == 10){
  50.                 counter = 1;
  51.                 System.out.print(i + " ");                    
  52.                 System.out.println();
  53.                 sor += i + " " + System.lineSeparator();
  54.                 writer.write(sor);
  55.                 sor = "";
  56.             }
  57.             else{
  58.                 System.out.print(i + " ");  
  59.                 sor += i + " ";
  60.                 ++counter;
  61.             }
  62.             ++szamlalo;
  63.         }
  64.        
  65.        
  66.         reader.close();
  67.         writer.close();
  68.     }
  69.    
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement