Beruflich Dokumente
Kultur Dokumente
int[]num={3,5,9,1,2,4,5,6};
ordename(num);
mostrarvectora(num);
}
static void mostrarvectora(int num[])
{
int k;
int l;
System.out.print("Ordenar de menor a mayor: ");
for(k=0;k<num.length;k++){
System.out.print(+num[k]);
}
System.out.println("==========");
System.out.println("Ordenar de mayor a menor");
for(l=7;l<num.length;l--)
{ System.out.print(+num[l]);
}
}
CONSOLA:
-1-
Ordenar de menor a mayor: 12345569
=========
Ordenar de mayor a menor
96554321
int k;
int[]num={3,5,9,1,2,4,5,6};
System.out.println("Ordenar de menor a mayor");
ordename(num);
for(k=0;k<num.length;k++){
System.out.print(+num[k]);
}
}
CONSOLA:
Ordenar de menor a mayor
12345569
-2-
static void mostrarvectora(int a[])
{
int i;
for(i=0;i<a.length;i++){
System.out.print(+a[i]);
}
}
System.out.print(+b[i]);
}
}
CONSOLA:
ordename(a);
int k;
for(k=0;k<a.length;k++){
System.out.print(+a[k]);
}
System.out.println(" ");
ordenabe(b);
int p;
for(p=0;p<b.length;p++){
System.out.print(+b[p]);
}
{
if(a[i]==b[i])
{
c[i]= a[i];
-3-
System.out.print(+a[i]);
}
}
}
CONSOLA:
12345569
12245889
La intersección es:
12459
-4-
2.C) RESTA DE DOS LISTAS
// Desplegamos el resultado:
for (int j=0; j<c.length; j++)
{System.out.println("c["+j+"]= "+c[j]);}
CONSOLA:
Resta dos listas (a-b)
c[0]= -5
c[1]= 3
c[2]= 8
c[3]= -7
c[4]= 0
c[5]= -5
c[6]= 1
c[7]= 1
-5-
4. Pasar a objetos : « El hogar es una casa que tiene una familia y una
mascota ».
System.out.println("APELLIDO DE LA FAMILIA1:"
+familia1.apellido);
System.out.println("DIRECCION DE LA FAMILIA1:"
+familia1.direccion);
System.out.println("TELEFONO DE LA FAMILIA1:"
+familia1.telefono);
System.out.println("MASCOTA DE LA FAMILIA1:"
+mascota1.nombre);
System.out.println("EDAD DE LA MASCOTA1:" +mascota1.edad);
System.out.println("
");
System.out.println("APELLIDO DE LA FAMILIA2:"
+familia2.apellido);
System.out.println("DIRECCION DE LA FAMILIA2:"
+familia2.direccion);
System.out.println("TELEFONO DE LA FAMILIA2:"
+familia2.telefono);
System.out.println("MASCOTA DE LA FAMILIA2:"
+mascota2.nombre);
System.out.println("EDAD DE LA MASCOTA2:" +mascota2.edad);
}
}
-6-
public class familia extends casa{
public String apellido;
public String direccion;
public int telefono;
this.apellido = papellido;
this.direccion = pdireccion;
this.telefono = ptelefono;
}
this.nombre = pnombre;
this.edad = pedad;
}
Consola:
APELLIDO DE LA FAMILIA1:Muñoz
DIRECCION DE LA FAMILIA1:Bruces F-69
TELEFONO DE LA FAMILIA1:1234567
MASCOTA DE LA FAMILIA1:Fido
EDAD DE LA MASCOTA1:7
APELLIDO DE LA FAMILIA2:Zarate
DIRECCION DE LA FAMILIA2:Jr. Bolivar 2056
TELEFONO DE LA FAMILIA2:1234567
MASCOTA DE LA FAMILIA2:pepino
EDAD DE LA MASCOTA2:8
-7-