Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Practica01;
- import java.util.*;
- import java.io.*;
- public class Test {
- /**
- * @param args
- */
- private static ArrayList<Integer> edificios = new ArrayList<Integer>();
- public static void main(String[] args) {
- long t;
- System.out.println("\t AVISO \n Este programa ha sido desarrollado por: \n - Javier Imbernon Molina \n - Juan Miguel Gabarron Segura \n");
- String dir = System.getProperty("user.dir")+File.separator+"CasosPrueba"+File.separator+"Practica01"+File.separator;
- System.out.println("El programa trabaja con las siguientes condiciones: \n - Las entradas deberán estar en: "+dir+"\n - Las entradas serán de numeros enteros (int) \n");
- generarEntradas(dir);
- try{
- FileWriter fw = new FileWriter(dir+"tiempos.txt");
- fw.write("Tiempos de creación de Skyline \n");
- for(int i = 0; i<20; i++){
- t = System.currentTimeMillis();
- Skyline s = new Skyline(dir+"entrada"+(i+1)+".txt",dir+"salida"+(i+1)+".txt");
- t=System.currentTimeMillis() - t;
- fw.write(edificios.get(i)+" edificios "+t+" milisegundos \n");
- }
- fw.close();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- public static void generarEntradas (String ruta){
- Random rd = new Random();
- int x,y,z;
- int line;
- for(int i = 0; i<20; i++){
- try{
- FileWriter fw = new FileWriter(ruta+"entrada"+(i+1)+".txt");
- line = rd.nextInt();
- while(line == 0 || line == 100 || line == -100) line = rd.nextInt();
- if(line<0)line*=-1;
- line=line%100;
- edificios.add(line);
- fw.write(line+"\n");
- for(;line!=0;line--){
- x=rd.nextInt();
- if(x<0)x*=-1;
- y=rd.nextInt();
- if(y<0)y*=-1;
- while(x==y){
- y=rd.nextInt();
- if(y<0)y*=-1;
- }
- if(y<x){
- int aux = x;
- x=y;
- y=aux;
- }
- z=rd.nextInt();
- if(z<0)z*=-1;
- fw.write(x%10000+", "+y%10000+", "+z%10000+"\n");
- }
- fw.close();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment