diff --git a/EF1.java b/EF1.java index 66ebb69..4cf0f57 100644 --- a/EF1.java +++ b/EF1.java @@ -1,15 +1,22 @@ -public class EF1{ - - public static void main(String args[]){ - int n = Integer.parseInt(args[0]); - System.out.println(Factorial(n)); - } - - public static int Factorial(int n){ - if(){//Escribir condición de salida - return 1; - }else{//Escribir el retorno para la recursividad - - } - } -} \ No newline at end of file +public class EF1 { + + + public static void main(String args[]) { + int n = Integer.parseInt(args[0]); + System.out.println(Factorial(n)); + + } + + public static int Factorial(int n) { + if (n<=0){ + return 0; + }else{ + if (n == 1) { + return 1; + } else { + return n * Factorial(n - 1); + } + } + } + + } \ No newline at end of file diff --git a/EF2.java b/EF2.java index c70e201..a08b9b1 100644 --- a/EF2.java +++ b/EF2.java @@ -1,9 +1,37 @@ -public class EF2{ - - public static void main(String args[]){ - - - } - - -} \ No newline at end of file + +public class EF2 { + + +public static void main(String[] args) { + + + int[] matriz= {2, 3, 8, 109, 13, 4, 18, 10, 23, 18, 50, 11, 13, 2}; + int aux; + + System.out.print("{"); + + for(int i=0;imatriz[j]) { + aux=matriz[i]; + matriz[i]=matriz[j]; + matriz[j]=aux; + + } + + } + + if(i