Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package numero.de.la.suerte;
- import java.io.*;
- import java.util.*;
- /**
- *
- * @author unstoppable
- *
- */
- public class NumeroDeLaSuerte {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- File archivo = null;
- FileReader fr = null;
- BufferedReader br = null;
- ArrayList<String> digito = new ArrayList<String>();
- ArrayList<String> luck = new ArrayList<String>();
- int lineas=0;
- try {
- archivo = new File ("datos.txt");
- fr = new FileReader (archivo);
- br = new BufferedReader(fr);
- String linea;
- boolean band = false;
- while( (linea=br.readLine()) != null && lineas != 50 && !band)
- {
- lineas++;
- String[] temp = linea.split(" ");
- if(Integer.parseInt(temp[0]) != -1){
- digito.add(temp[0]);
- luck.add(temp[1]);
- }else{
- band=true;
- }
- }
- }
- catch(Exception e){
- e.printStackTrace();
- }finally{
- try{
- if( null != fr ){
- fr.close();
- }
- }catch (Exception e2){
- e2.printStackTrace();
- }
- }
- String conv, resultado="";
- int cont=0;
- int mayor=0;
- System.out.println("Salida");
- for (int i = 0; i < digito.size(); i++)
- {
- conv="";
- mayor=0;
- for (int j = 2; j < 10; j++)
- {
- cont=0;
- conv = Integer.toString((Integer.parseInt(digito.get(i))), j);
- for (int k = 0; k < conv.length(); k++)
- {
- if(conv.charAt(k) == luck.get(i).charAt(0)){
- cont++;
- if(cont >= mayor){
- mayor = cont;
- resultado = conv;
- }
- }
- }
- }
- System.out.println(resultado);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement