Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Punto7 {
- public static Scanner scanner = new Scanner(System.in);
- public static int forceReadPositiveInteger(String msg)
- {
- int ret = 0;
- while(true)
- {
- try
- {
- System.out.println(msg);
- while((ret = Integer.parseInt(scanner.next())) < 1) System.out.println("El número a cargar debe ser positivo.\n"+msg);
- return ret;
- }catch (Exception e) {
- System.out.println("Error en la carga.");
- }
- }
- }
- public static void main(String[] args) {
- int n = forceReadPositiveInteger("¿Cuántos números ingresará al árbol?");
- AVLTree avl = new AVLTree();
- while((n--) > 0)
- {
- int x = forceReadPositiveInteger("Ingrese número a ingresar");
- avl.root = avl.insert(avl.root, x);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement