Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Mauricio_Siu_Prueba1Recursiva {
- int[] Lista;
- public Mauricio_Siu_Prueba1Recursiva(int longitud) {
- this.Lista = new int[longitud];
- }
- public void Llenar(int x) {
- Scanner r = new Scanner(System.in);
- int valores;
- if (x < Lista.length) {
- System.out.print("Digite los Valores:");
- valores = r.nextInt();
- Lista[x] = valores;
- Llenar(x + 1);
- }
- }
- public void Print(int x) {
- if (x < Lista.length) {
- System.out.println(Lista[x]);
- Print(x + 1);
- }
- }
- public int Suma(int x, int total) {
- if (x < Lista.length) {
- total += Lista[x];
- Suma(x + 1, total);
- System.out.println("Total " + total);
- }
- return total;
- }
- public boolean buscar(int x, int n) {
- if (x < Lista.length) {
- if (n == Lista[x]) {
- System.out.println("Se Encontro");
- return true;
- }
- buscar(x + 1, n);
- }
- return false;
- }
- public void reemplazar(int x, int n, int m) {
- if (x < Lista.length) {
- if (n == Lista[x]) {
- Lista[x] = m;
- Print(0);
- }
- reemplazar(x + 1, n, m);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement