Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Mauricio_Siu_Prueba1Recursiva {
  5.  
  6. int[] Lista;
  7.  
  8. public Mauricio_Siu_Prueba1Recursiva(int longitud) {
  9. this.Lista = new int[longitud];
  10. }
  11.  
  12. public void Llenar(int x) {
  13. Scanner r = new Scanner(System.in);
  14. int valores;
  15. if (x < Lista.length) {
  16. System.out.print("Digite los Valores:");
  17. valores = r.nextInt();
  18. Lista[x] = valores;
  19. Llenar(x + 1);
  20. }
  21. }
  22.  
  23. public void Print(int x) {
  24. if (x < Lista.length) {
  25. System.out.println(Lista[x]);
  26. Print(x + 1);
  27. }
  28. }
  29.  
  30. public int Suma(int x, int total) {
  31. if (x < Lista.length) {
  32. total += Lista[x];
  33. Suma(x + 1, total);
  34. System.out.println("Total " + total);
  35. }
  36. return total;
  37. }
  38.  
  39. public boolean buscar(int x, int n) {
  40. if (x < Lista.length) {
  41. if (n == Lista[x]) {
  42. System.out.println("Se Encontro");
  43. return true;
  44. }
  45. buscar(x + 1, n);
  46. }
  47. return false;
  48. }
  49.  
  50. public void reemplazar(int x, int n, int m) {
  51. if (x < Lista.length) {
  52. if (n == Lista[x]) {
  53. Lista[x] = m;
  54. Print(0);
  55. }
  56. reemplazar(x + 1, n, m);
  57. }
  58.  
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement