Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lotto;
- import java.io.*;
- import java.util.*;
- public class Lotto {
- public static void main(String[] args) throws IOException {
- String file = "lotto.txt";
- String kiFile = "eredmeny.txt";
- Reader reader = new FileReader(file);
- Writer writer = new FileWriter(kiFile);
- Scanner sc = new Scanner(reader);
- List<String> sorok = new ArrayList<>();
- String[] szamok;
- int[] lottoSzamok = new int[5];
- int[] nyeroSzamok = new int[90];
- while(sc.hasNext()){
- sorok.add(sc.nextLine());
- }
- try{
- for(String a: sorok){
- szamok = a.split(" ");
- lottoSzamok[0] = Integer.parseInt(szamok[15]);
- lottoSzamok[1] = Integer.parseInt(szamok[16]);
- lottoSzamok[2] = Integer.parseInt(szamok[17]);
- lottoSzamok[3] = Integer.parseInt(szamok[18]);
- lottoSzamok[4] = Integer.parseInt(szamok[19]);
- for(int i: lottoSzamok){
- //System.out.print(i + " ");
- ++nyeroSzamok[i-1];
- }
- //System.out.println();
- }
- }
- catch(NumberFormatException e){
- }
- int szamlalo = 1;
- int counter = 1;
- String sor = "";
- for(int i : nyeroSzamok){
- if(counter == 10){
- counter = 1;
- System.out.print(i + " ");
- System.out.println();
- sor += i + " " + System.lineSeparator();
- writer.write(sor);
- sor = "";
- }
- else{
- System.out.print(i + " ");
- sor += i + " ";
- ++counter;
- }
- ++szamlalo;
- }
- reader.close();
- writer.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement